Hello i wanted to include a script that prevent users to make multi submission so far soo good it is working in on way that it block the user from redirecting to the destination.html after submitting one time but i get all the information even when he get the error message . So the question is this i dont know where exactly to put this code or use it for my needs :
if (!isset($_SESSION['validsubmit']) || !$_SESSION['validsubmit']) {
echo "ERROR: Invalid form submission, or form already submitted!";
} else {
$_SESSION['validsubmit'] = false;
}
Inside my proces php form here the shoren version :
<?php
session_start();
require_once('formvalidator.php');
if(isset($_POST['form_btn'])) {
$validator = new simple_fv;
// fields info container
$fields = array();
// fill the container with fields data
$fields[] = array('index'=>'name', 'label'=>'Name', 'required'=>true, 'max_len'=>25);
$fields[] = array('index'=>'surname', 'label'=>'surname', 'required'=>true, 'max_len'=>30);
$indexes[] = array('index'=>'email', 'label'=>'E-mail', 'required'=>true, 'type'=>'email', 'max_len'=>200);
$fields[] = array('index'=>'phone', 'label'=>'phone number', 'required'=>true, 'type'=>'int', 'min_len'=>4);
// validate the fields
$validator->formHandle($fields);
// get errors
$error = $validator->getErrors();
// if errors is not FALSE - print the succesfull message
if($error) {echo $error;}
else {if( isset($_POST['name']) )
$emotion = $_POST['emotion'];
if($emotion == 'Basic Pack') {
session_start();
$_SESSION['form_finished'] = true;
header('Location: /destination/basicc.php');
} elseif($emotion == 'Deluxe Pack') {
header('Location: html6.php');
} elseif($emotion == 'Premium Pack') {
header('Location: html7.php');
}
$to = 'myemail@gmail.com';
$subject = 'NEWLOGO CLIENT FORM';
$headers = 'From: ' . $_POST['email'] . "
" . 'Reply-To: ' . $_POST['email'];
$message = 'Name: ' . $_POST['name'] . "
" .
'Surname: ' . $_POST['surname'] . "
" .
'E-mail: ' . $_POST['email'] . "
" .
'Phone: ' . $_POST['phone']. "
" .
mail($to, $subject, $message, $headers);
if( $_POST['copy'] == 'on' )
{
mail($_POST['email'], $subject, $message, $headers);
} }
}
?>
I want to make it so that on the first submit the user go to my redictet page but on the second time not just to show this echo "ERROR: Invalid form submission, or form already submitted!"
and the email need to not be send in that case.