Hi,
I have a PHP file that writes form inputs into a csv file. I redirect user to a thank-you.php page when they fill the form for the first time. If user tries to fill the form again, I want to redirect them to another page (already-there.php). I recognize users based on their emails. So if an email already exists in the csv file, do not write the entry into the file again and redirect the person to the ‘already-there.php’ page. But the problem is that it keeps going to the ‘thank-you.php page’. Here is my code. I appreciate it if any one could tell me where the problem is:
[CODE]
<?php
$keys = array(‘Name’,’Email’,’Phone’);
$csv_line = array();
foreach($keys as $key){
array_push($csv_line,” . $_POST[$key]);
}
$fname = ‘form_inputs.csv’;
$csv_line = implode(‘,’,$csv_line);
if(!file_exists($fname)){$csv_line = “rn” . $csv_line;}
$fcon = fopen($fname,’a’);
$file_content_separated_by_colon = explode(“,”, $fname);
echo $file_content_separated_by_colon;
if( strpos($file_content_separated_by_colon, $_POST[‘Email’]) == false) {
fwrite($fcon,$csv_line . “n”);
fclose($fcon);
header(‘Location: thank-you.php’);
}
else {
header(‘Location: already-there.php’);
}
exit();
?>
Tried it with 3 equal signs too like this: === false, no help.
Thanks in advance!