I have a form but I want it only being sent once per user, so I want to set a cookie to do that. How do I have to change my script?
My PHP script:
<?php
if (isset($_COOKIE["Form"]) == 1)
{
//Hide form
exit();
}
if ( $_GET['value'] <> "")
{
$adress = 'Receiver@mysite.com';
$subject = 'SUBJECT';
$text = 'TEXT';
mail($adress,
$subject,
$text,
'From: someone@mail.here');
$handle = fopen ( "some-doc.txt", "a" );
fwrite ( $handle, $_GET['value'] );
fclose ( $handle );
echo "Thanks";
setcookie("Form", 1, time()+3600*24*60); // Line 108
exit;
}
?>
Error Message
Warning: Cannot modify header information - headers already sent by (output started at
form.php:6) in
form.php on line 108
I changed it but now I get this error.
I see that you did:
setcookie("Schule", 1, time()+3600*24*60);
Then use similar approach:
setcookie("Form", 'yes', time()+3600*24*60);
Now:
if (isset($_COOKIE["Form"]) && $_COOKIE["Form"] == 'yes')
{
//Hide form
exit();
}