create a back button. Would user info still be there?

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
pugs421
New php-forum User
New php-forum User
Posts: 31
Joined: Sat Jun 28, 2003 9:09 pm

Sun Jul 13, 2003 12:20 pm

I know there are ways to resubmit the user info but I'm a novice and I can only do so much. As of now my form vaildation will display ex. "You must fill in your address" on a seperate page. If I somehow make a back button on that page using php will the info the user filled into the form stay there? Does it depend on the browser?

liquedus
php-forum Active User
php-forum Active User
Posts: 264
Joined: Tue Apr 08, 2003 5:18 am
Location: Ottawa, Canada
Contact:

Sun Jul 13, 2003 12:38 pm

im pretty sure that, unless you clear the boxes with page load, that hitting the history.go(-1) in javascript will keep the values there, and i also think that hitting the back button works to the same effect.

pugs421
New php-forum User
New php-forum User
Posts: 31
Joined: Sat Jun 28, 2003 9:09 pm

Sun Jul 13, 2003 12:50 pm

oh. I can just do it with javascript huh? I know they could hit the back button but I figured it would be more user friendly to provide one. I'll give that a try. thanks.

User avatar
swirlee
Moderator
Moderator
Posts: 2257
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Sun Jul 13, 2003 6:48 pm

This is the second time I've answered this question today. The usual method is to make the form submit to itself (i.e. <form action="<?= $_SERVER['PHP_SELF'] ?>" ...>). Then on the page with the form, check to see if the form has been submitted. If it has, do your validation, and if anything is missing, display the form again with all the submitted information filled in (i.e. <input type="text" name="username" value="<?= $_REQUEST['username'] ?>">) and highlight the fields that the user missed. For the record, form validation is a pain in the arse. I recommend reading one of the dozens of good form validation tutorials that Google will find for you and/or don't reinvent the wheel and just download someone else's script.
Image

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests