avoid duplicated mails on browser refresh
Posted: Mon Aug 02, 2010 12:06 pm
Hello, guys. I'm using the following code to send me an automated mail in case the user find a broken link. But there are 2 problems: 1) after submitting I'd rather not disrupt their game by refreshing the page. So, is there any way to send mail without the post refreshing? 2) if the user hits F5, the page reloads and the code runs again, sending two or more times the same email. How can I avoid duplicated emails caused by manual browser refresh?
Code: Select all
<form name="fbrlink" action="<?= $_SERVER['PHP_SELF']."?page=ok" ?>" method="post">
<?php
echo('<input name="sbrlink" id="B1" type="button" value="broken Link?" style="border:none; background-color:#FFFFFF; font-family:Trebuchet MS; font-size:15px; font-weight:bold; color:#1A4877; cursor:pointer; display:block; text-decoration:underline;" onclick="this.form.submit();"/>');
?>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{ if ($_SERVER['QUERY_STRING'] == 'page=ok') {
echo '<script type="text/javascript" >confirm("Click OK to notify us.");</script>';
mail("contact@ctt.net","report broken link","Game notified:MarioBros");
echo '<script type="text/javascript" >document.fbrlink.sbrlink.disabled = true;</script>';
?>
<script type="text/javascript" >document.fbrlink.action='<?php echo $a; ?>';
alert('<?php $_SERVER['QUERY_STRING'];?>');
</script>
<?php
}
else {}
}else{
}
?>