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

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
SashaSlutsker
Forum Newbie
Posts: 18
Joined: Sat Mar 20, 2004 11:24 am

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

Post 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?
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post 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
SashaSlutsker
Forum Newbie
Posts: 18
Joined: Sat Mar 20, 2004 11:24 am

Post 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.
doeboy
Forum Newbie
Posts: 10
Joined: Sun Mar 21, 2004 10:18 am

Post 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.
Post Reply