chop Posted April 12, 2012 Share Posted April 12, 2012 I am working on an unusual website, one that uses jquery and is horizontally scrolling with each "page" of the site displayed as a separate "panel". This means that the entire website exists as "index.php" The very last panel is the Contact page. I have set up a simple php mailer to wrap and send information on Name, Email, Comment ... the usual. Everything works fine except if the user clicks on "refresh" button on the browser in which case the email, with all the same information, is sent again. It doesn't matter what panel you're on, the email will be sent. At the very top of the Body section, I have: if (isset($_POST['submitted']) && isset($_POST['sendEmail']) ) { where "$_POST['sendEmail'])" is in a hidden field. I also have: $_POST = array(); after the email is sent to clear the POST array... I thought this would handle the problem! But the information is still there and will repeat if the Refresh is pressed!. How do I clear the information so the Refresh information is cleared? What is the best thing to do here? Link to comment Share on other sites More sharing options...
bahaa Posted April 12, 2012 Share Posted April 12, 2012 I had the same problem with my pages and my solution to this was to store any messages I want to pass with a cookie or session and upon submission I do redirect to the same page then I echo my cookie or msg and then set it to null. Link to comment Share on other sites More sharing options...
chop Posted April 12, 2012 Author Share Posted April 12, 2012 I'm wondering how the "isset" conditional is accessed if I delete all the $_POST vars. I suppose their must be a buffer that holds onto them for the purpose of resending the data when the refresh is pressed?? I thought that maybe a redirect would clear everything but that didn't work either. I can try the cookie method and see how that works. hanks Link to comment Share on other sites More sharing options...
Recommended Posts