Canman2005 Posted September 23, 2007 Share Posted September 23, 2007 Hi all I have a simple contact form which is POSTED to a simple email script. At the end of the email script, I have put the following print "<script>alert('Thank you, your message has been sent');</script>"; print "<script>location.replace('index.php?id=25');</script>"; exit; The problem is that once the script has run, if you click the back button, the form seems to want to POST again. Does anyone know why this happens and if I can stop it from happening Thanks Dave Link to comment https://forums.phpfreaks.com/topic/70358-form-submitting-twice/ Share on other sites More sharing options...
cooldude832 Posted September 23, 2007 Share Posted September 23, 2007 Best way to lock a form from double submission is once processing occurs set a session saying the form is submitted so they can't resubmit like Processer.php <?php session_start(); if($_SESSION['submitted'] == "yes"){ //Don't double submit header("location: form.php?error=double+submit"); } ?> Link to comment https://forums.phpfreaks.com/topic/70358-form-submitting-twice/#findComment-353438 Share on other sites More sharing options...
AV1611 Posted September 23, 2007 Share Posted September 23, 2007 You so smart Link to comment https://forums.phpfreaks.com/topic/70358-form-submitting-twice/#findComment-353445 Share on other sites More sharing options...
cooldude832 Posted September 23, 2007 Share Posted September 23, 2007 I should state that if the user properly reopens the form (Say they want to submit another row) you need to reset the session to no Link to comment https://forums.phpfreaks.com/topic/70358-form-submitting-twice/#findComment-353447 Share on other sites More sharing options...
Canman2005 Posted September 23, 2007 Author Share Posted September 23, 2007 thank you Link to comment https://forums.phpfreaks.com/topic/70358-form-submitting-twice/#findComment-353449 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.