Sessions or cookies

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
leebo
Forum Commoner
Posts: 44
Joined: Sun Oct 20, 2002 9:49 am

Sessions or cookies

Post by leebo »

I have made a form which i want a user to only access once. I need some ideas on how i can do this.

I have a page which will post the info - form.php?user=ok
they can then fill out the form and press submit - however when you press the back button they go back to the form.php and it will let them back in and submit again - how can i stop them from submitting twice ? could i do this using cookies ? but what if the user has cookies disabled ?

HELP PLS
:wink:
pootergeist
Forum Contributor
Posts: 273
Joined: Thu Feb 27, 2003 7:22 am
Location: UK

Post by pootergeist »

sessions are your friend and really simple to use in recent builds - I strongly advise using them, they'd be perfect for that situation.
leebo
Forum Commoner
Posts: 44
Joined: Sun Oct 20, 2002 9:49 am

Post by leebo »

So how would i do this ? i have tried using session but when the browser back button is clicked it some how doesn`t register without refreshing the page first ?

Can anyone help me solve this problem. Thanks
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post by daven »

viewtopic.php?t=6521

Check out that sticky about sessions
oldtimer
Forum Contributor
Posts: 204
Joined: Sun Nov 03, 2002 8:21 pm
Location: Washington State

Post by oldtimer »

You can also put a refresh on that page.

When they hit submit the form processes' then refreshed to whatever page which in return goes to the page you really want them to see when they are done. I use this in logouts.

They click on Logout. It takes them to the logout page kills the session then uses the refresh to a new page and then there it uses the refresh in the header back to index or whatever. Hitting the back button will not take them back to the page they just submited from. I just make the delay 0 seconds.
mattd
Forum Newbie
Posts: 6
Joined: Wed Mar 26, 2003 10:10 pm

sessions

Post by mattd »

you should read that sticky..

do this:

if ($_SESSION['viewed_form'] == true)
{
echo "You already saw this!";
or
add refresh code
} else {
echo "put your form";
$_SESSION['viewed_form'] = true;
}
Post Reply