Seeking design advice.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jack.Straw
Forum Newbie
Posts: 11
Joined: Thu Nov 30, 2006 11:12 am

Seeking design advice.

Post by Jack.Straw »

Hi. Is there a way to give people a 'page expired' message if they use the 'Back' button on their browser? Here's the scenario:
  • User fills out a form and submits it.
  • On submittal the browser uses CGIemail to email the form contents back to the user.
  • The CGIemail 'success' value instructs the browser to load a custom success page, where a hidden form with hidden values is auto-submitted, using CGIemail again to send another email to an administrator.
  • The CGIemail 'success' value from the 2nd 'hidden' form instructs the browser to load the real success page, where the user is notified that the process was a success.
This all works great. When the user submits the form an email is sent to their email address, and then another email containing different information is sent to an administrator. However, if the user tries to use the 'back' button on their browser from the final success page, a duplicate email gets sent. How could i prevent this?

Thanks in advance of any advice you can offer!
-Jack
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Use php sessions... when the email is sent, set that time in a session variable:

Code: Select all

$_SESSION['email_sent_time'] = time();
Then check that before sending the email (to make sure none have been sent from that particular user in the last 100 seconds or minute (or whatever you want)

Code: Select all

if((time() - $_SESSION['email_sent_time']) > 100 /* Whatever time limit you want */){
    // Send email
}
Post Reply