my php email for is sending emails every time the page is refreshed. For example the user is filling out the form and sending it with the send button. That\'s all fine and g
Use a header instead and make sure you have no output before header.
if(!$mail->Send()) {
header("Location: http://www.example.com");
exit;
}
If that does not work for you, use a meta refresh method:
if(!$mail->Send()) {
$to = "http://www.example.com";
$url = $to;
print "";
exit;
}
or display a message and redirect after 5 seconds:
if(!$mail->Send()) {
$to = "http://www.example.com";
$url = $to;
print "";
print "Thank you for your message.";
exit;
}
Edit: (cookie/token method)
You can use a cookie and this is just an example.
You can not submit this form twice.';
echo $error_list;
echo '
Thank you, your message has been sent. You do not need resubmit it again.
';
exit;
}
foreach( $_POST as $values ) { $data .= $values . "
"; echo $data; }
}
?>