RE: [PHP] HELP! form validation
Hi Jim, Ive modified the code for the form by adding the style info vars to the relevant fields and set the var for the error style but for some reason the $error_var wont pick up the syle from $error_syle_var. Eg: $error_style = 'color: rgb(255,0,0)'; if(!$name){$err1 = $error_style; $error[]=*please enter your name\n;} $err1 does not pick up $error_style in the actual form and I just get style= instead of style=color: rgb(255,0,0). Im a tad baffled and im sure its something simple that im missing. Any ideas? Cheers Dave -Original Message- From: Jim Moseby [mailto:[EMAIL PROTECTED] Sent: 08 June 2005 15:33 To: '[EMAIL PROTECTED]' Subject: RE: [PHP] HELP! form validation I can see that being a very nice way of doing it. I will get on and give it a go this afternoon. Thanks so much for the speedy response! It just so happened that I, just last week, wanted to do what you are doing. Fortunately, being the poor housekeeper that I am, I still had that piece of trial code on my server. Good luck with it, and don't judge my sloppy code too harshly! :o) JM -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.6.5 - Release Date: 07/06/2005 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.6.6 - Release Date: 08/06/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] HELP! form validation
Hi Jim, Ive modified the code for the form by adding the style info vars to the relevant fields and set the var for the error style but for some reason the $error_var wont pick up the syle from $error_syle_var. Eg: $error_style = 'color: rgb(255,0,0)'; if(!$name){$err1 = $error_style; $error[]=*please enter your name\n;} $err1 does not pick up $error_style in the actual form and I just get style= instead of style=color: rgb(255,0,0). Im a tad baffled and im sure its something simple that im missing. Any ideas? Does it re-populate the fields with the previously entered data? If not, register_globals might be off, and you'll have to set the variables manually: $name=$_POST['name']; ...or use them directly: if (!$_POST['name']){...} JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HELP! form validation
Yes, it does. I already have set the variables manually like you say. Its just the $err1, $err2 vars do not seem to be set with the data stored in $error_style. Dave -Original Message- From: Jim Moseby [mailto:[EMAIL PROTECTED] Sent: 09 June 2005 15:02 To: '[EMAIL PROTECTED]'; Jim Moseby Cc: php-general@lists.php.net Subject: RE: [PHP] HELP! form validation Hi Jim, Ive modified the code for the form by adding the style info vars to the relevant fields and set the var for the error style but for some reason the $error_var wont pick up the syle from $error_syle_var. Eg: $error_style = 'color: rgb(255,0,0)'; if(!$name){$err1 = $error_style; $error[]=*please enter your name\n;} $err1 does not pick up $error_style in the actual form and I just get style= instead of style=color: rgb(255,0,0). Im a tad baffled and im sure its something simple that im missing. Any ideas? Does it re-populate the fields with the previously entered data? If not, register_globals might be off, and you'll have to set the variables manually: $name=$_POST['name']; ...or use them directly: if (!$_POST['name']){...} JM -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.6.6 - Release Date: 08/06/2005 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.6.6 - Release Date: 08/06/2005 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.6.6 - Release Date: 08/06/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] HELP! form validation
Eg: $error_style = 'color: rgb(255,0,0)'; if(!$name){$err1 = $error_style; $error[]=*please enter your name\n;} snip! Does it re-populate the fields with the previously entered data? Yes, it does. I already have set the variables manually like you say. Its just the $err1, $err2 vars do not seem to be set with the data stored in $error_style. This baffles me too then. In your code above, if $name is not set, $err1 will be set to equal $error_style. There is obviously more coming into play than just this code snippet. Double-check your variable names. Place strategically located 'echo' statements to see what is happening, for instance, right after the above 'if' statement, place an 'echo $name;'. JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] HELP! form validation
Thanks jim, sorry for troubling you. Ive done that now and can see that all vars are being set but the code in the form to return the contents of $err1 doesnt display the contents, just emptiness. Thanks for your help, I will keep on playing with it. Cheers Dave -Original Message- From: Jim Moseby [mailto:[EMAIL PROTECTED] Sent: 09 June 2005 15:49 To: '[EMAIL PROTECTED]'; php-general@lists.php.net Subject: RE: [PHP] HELP! form validation Eg: $error_style = 'color: rgb(255,0,0)'; if(!$name){$err1 = $error_style; $error[]=*please enter your name\n;} snip! Does it re-populate the fields with the previously entered data? Yes, it does. I already have set the variables manually like you say. Its just the $err1, $err2 vars do not seem to be set with the data stored in $error_style. This baffles me too then. In your code above, if $name is not set, $err1 will be set to equal $error_style. There is obviously more coming into play than just this code snippet. Double-check your variable names. Place strategically located 'echo' statements to see what is happening, for instance, right after the above 'if' statement, place an 'echo $name;'. JM -- No virus found in this incoming message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.6.6 - Release Date: 08/06/2005 -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.6.6 - Release Date: 08/06/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HELP! form validation
On 6/8/05, Dave Sayer [EMAIL PROTECTED] wrote: What would be the best method of validation a large (8 stages) form written in php? The form validates using php at the moment but it only displays the errors in a group, what we want it to do is highlight the fields or labels for the incorrect entries (if that makes sense.) so the user can easily see where to correct their mistakes. Any advice, or links to good resources would be great!! I do not really know javascript so a php solution would be preferable. You might want to have a look at the following links: http://kalsey.com/simplified/form_errors/ http://www.sitepoint.com/print/practical-xml-form-validation http://simon.incutio.com/archive/2003/06/17/theHolyGrail I use a slightly modified version of Kalsey's method on my weblog and it works quite well. Paul -- Rogue Tory http://www.roguetory.org.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] HELP! form validation
Hi phpers, What would be the best method of validation a large (8 stages) form written in php? The form validates using php at the moment but it only displays the errors in a group, what we want it to do is highlight the fields or labels for the incorrect entries (if that makes sense.) so the user can easily see where to correct their mistakes. Any advice, or links to good resources would be great!! I do not really know javascript so a php solution would be preferable. Hi Dave - I sent you a private message with sample code attached. What I do is, when the form is submitted, validate the fields, and if any are invalid, redisplay the form with the fields pre-populated with the previous values and change the background color of the fields in question. JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] HELP! form validation
-Original Message- From: Jim Moseby [mailto:[EMAIL PROTECTED] Sent: 08 June 2005 15:18 To: '[EMAIL PROTECTED]' Subject: RE: [PHP] HELP! form validation -Original Message- From: Dave Sayer [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 08, 2005 9:58 AM To: php-general@lists.php.net Subject: [PHP] HELP! form validation Hi phpers, What would be the best method of validation a large (8 stages) form written in php? The form validates using php at the moment but it only displays the errors in a group, what we want it to do is highlight the fields or labels for the incorrect entries (if that makes sense.) so the user can easily see where to correct their mistakes. Any advice, or links to good resources would be great!! I do not really know javascript so a php solution would be preferable. Hi Dave, I have attached a simple example of how I do it. You may be able to adapt it to your own situation. Jim Hi Jim, I can see that being a very nice way of doing it. I will get on and give it a go this afternoon. Thanks so much for the speedy response! Cheers, Dave -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.323 / Virus Database: 267.6.5 - Release Date: 07/06/2005 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php