I have php page where I used a form to submit messaage. It submits to itself :
action="<? php echo $_SERVER['PHP_SELF'];?>"
Then it sends email, and I have a javascript function that uses jnotify, to alert whether message is sent successfully or not. This function checks if php variable $sent==’yes’ then notify about sucessful message else notify about error.
The problem is that when user sends message and goes to another page and comes back by using browsers back button, it is displaying notification. I want it to show notification once only and forget about notification when browsers back or refresh used.
What is the best solution for it?
Try something like this:
This should make it so they only see the success/failure message once, and if they use the back button at a later time, they will not receive a warning about re-submitting post data, and they also won’t see a success/failure message twice. The only time that javascript should show is if they just submitted the form in the last request.