Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

unsetting POST arry

Status
Not open for further replies.

bam720

Technical User
Sep 29, 2005
289
US
I have a simple form which just posts back to itself. I want to unset the POST array so that if you refresh the page the form doesn't get resubmitted. I do a test at the beginning of the script like:
if(isset($_POST['name']))
but then when I call unset($_POST['name']) nothing really happens, becuase if I refresh I still get a dupe. Any ideas?
 
Uh, refreshing the page is probably resubmitting the values in memory. To my knowledge, unless you programmatically send/set values in the "value=" or "checked=" (etc.) html code for the form when you reprocess the submit you wouldn't have any values returning to tthe posted form.

BUT, if you submit a form and then CTRL-R or otherwise refresh that page (if it calls itself) I suspect you're tripping over yourself.

I might be missing something here....

D.E.R. Management - IT Project Management Consulting
 
I'm just thinking from a Users standpoint. I don't want them to submit and then refresh, to cause this. Or am I overthinking?
 
include a hidden field in the form. insert a unique id into the field and save the value to a session variable.

on submission:
1. check for the presence of the hidden key and the session var.
2. if the values are identical, allow the submission and then unset the session variable.

if the form is resubmitted then the values will not be identical and you can ignore the submission and redirect appropriately.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top