How to disable form reloading
Say you have a form, the information sent to the form is via $_GET, all other details from the forms input are pulled from a database, do a few checks to make sure everything is ok, then submit new info to database and forward person to another page (via header location), this all works great and everything BUT if a person submits the form they can use the back button to go back to that page (they get forwarded on again) but the info is resubmitted into database.
I've tried redirecting through two pages (via header location) and unsetting (unset($var)) but nothing seems to work, any ideas (without disabling the back button) ?
** thinking out aloud **
thinking of trying sessions, but problem is they can come to this page from one of two pages and get sent back to the one they came from, or I could use a third page to give them the option where to go next and expire the session there but if they go to the form and dont submit the info the session wont expire.
** stop thinking, smoke to thick **
mairving posted this at 12:41 — 6th March 2004.
They have: 2,256 posts
Joined: Feb 2001
Just validate the data going into the database. If the record already exist, don't add it again.
Busy posted this at 21:21 — 6th March 2004.
He has: 6,151 posts
Joined: May 2001
One of the first things on the page is a check to see if its been already added or not (not for this going back problem) but because the info is still in the cache and validates its able to be added again as I found out accidently.
Suzanne posted this at 22:56 — 6th March 2004.
She has: 5,507 posts
Joined: Feb 2000
You could set the $var to something in particular, such as ""?
Busy posted this at 04:18 — 7th March 2004.
He has: 6,151 posts
Joined: May 2001
Tried that too, but can only place it before or after the input checks and it checks out
I think I have it sorted,
set a session variable after the database input (data_input.$id) and a check at top of page to see if it's been set, this is the only way I could find to stop it happening.
Just hope if a lot of inputing is done it doesn't overload the session values (can't test that for a while)
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.