Jump to content

Form submitting twice


Canman2005

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.