|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
?simple? forms question
hi,
I'm creating a registration page for my website, and am wondering how, when someone enters some information into a form, but then an error occurs(such as username already taken), and I display the error, how do I maintain the information already in placed in the form? ie. if they enter there name, email, but enter a username that is already taken. How do I display an error, and keep their name and email already in the form? the current version of my code is at URL with the running version at URL any ideas? thanks, joel |
|
#2
|
|||
|
|||
|
after it shows the errors make a link with the src as "javascript:history.back(-1);" that should keep the information they typed in the form.
like: Quote:
edit: remove the space between java and script. the forum automatically inserts a space for some reason...
__________________
![]() ![]() "Only Linux users see the end of crashes." - Pl4t0 Last edited by wAr-AnGeL : January 2nd, 2003 at 03:30 AM. |
|
#3
|
|||
|
|||
|
You could loop through the $_POST associative array with something like this:
<?php foreach($_POST as $k => $v) { echo "<input type='hidden' name='$k' value='$v'>\r\n"; } That would output the entire form contents, such as: <input type='hidden' name='a' value='first'> <input type='hidden' name='b' value='second'> <input type='hidden' name='c' value='third'> etc... Just remember that javascript:history.go(-1) wont work on some browser, mainly some versions of IE6 that have a bug. |
|
#4
|
|||
|
|||
|
thanks,
i didn't think about using the $_POST variables again... now I just use them as "value=$_POST['varName']" in each field had to slightly change the way I did my error messaging to get it to work. Because before, submit would call the page itself when form was entered, then when an error occured, the page would be called again with "?error=#". and with the second call I lost the POST variables. so I had to redo how I dealt with errors a little bit, but no big change. thanks, joel |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > ?simple? forms question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|