Page 1 of 1

Filling in forms with a PHP script/preventing accidental...

Posted: Sat Mar 20, 2004 11:24 am
by SashaSlutsker
..sending. Sorry, I couldn't fit the entire topic. Anyway...

I have a PHP form on my site. Anyway, everytime someone refreshes the page or presses back into the form it resends the information to the page. (It's post action is to itself.) Anyway, this is a BIG problem. Does anyone know how to make it so that it only submits the form when the user presses the send button?

Alternatively, I could also set all the values of the form to 0 after they submit, but I don't know how I would do that either.

Either would fix the problem, does anyone know how to do it?

Posted: Sat Mar 20, 2004 11:44 am
by PrObLeM
use sessions

http://www.php.net/manual/en/ref.session.php

and set a value to the session and if that value is there dont show the form


i think that should help

Posted: Sat Mar 20, 2004 11:54 am
by SashaSlutsker
I already use sessions. And the thing is, I need them to be able to fill in this form as many times as they want. However, I need to prevent ACCIDENTAL filling out of the form.

Posted: Sun Mar 21, 2004 11:27 am
by doeboy
You can reset $_POST values. Just do $_POST['var'] = "". Then in your process script make sure you check that there are values to insert.

Alternatively if you are allowing your users to submit the form more than once, but they must enter new data each time, you could check the database to see if the data is the exact same that is already in there.