Prevention of Double Send
I just wrote a simple E-mail form that I have on my homepage but I found 1 slight bug and I dont know how to fix it. What happends is after you submit an E-mail It shows E-mail sent or whatever but if you refresh the page it sends the e-mail again. Here is the code:
<?
if (isset($_REQUEST['page'])) {
$id = $_REQUEST['page']; }
if($page == sent) {
$message = "$mess
Ip: $REMOTE_ADDR";
$toaddy = "[email protected]";
$test = "E-mail";
$testt = "Comment";
//I made the Comment Was Sent! so spammers won't know that if they click send without changing whats in the text boxes that it wont send so that way they will waste there time clicking that and not waste my time with spam...
if($message == $testt){echo "Comment Was Sent!";}
elseif($fromaddy == $test){echo "Comment Was Sent!";}
elseif($mess == $testt){echo "Comment Was Sent!";}
elseif($fromaddy == NULL){echo "Comment Was Sent!";}
elseif($mess == NULL){echo "Comment Was Sent!";}
else {mail($toaddy, "Comment!", $message, "From:$fromaddy");
echo "Comment was Sent!";}}
else {
echo "<form action=\"$phpself?page=sent\" method=\"post\">
<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
<tr>
<td> <input type=\"text\" name=\"fromaddy\" value=\"E-mail\" size=\"14\"></td>
</tr>
<tr>
<td> <textarea name=\"mess\" rows=3 cols=10>Comment</textarea></td>
</tr>
<tr>
<td>
<input type=\"submit\" value=\"Submit\"></form></td>
</tr>
</table>";}
?>
Thanks!