This is a discussion on "PHP Form Validation ???" within the PHP Forum section. This forum, and the thread "PHP Form Validation ??? are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
PHP Form Validation ???
|
||
| Notices |
![]() |
|
|
LinkBack (1) | Thread Tools |
#1
|
|||
|
|||
|
I wonder if anyone around could possibly enlighten me a little (or indeed, a LOT) towards "Contact Us" form validation in PHP.
Basically, I've created the form & then typed in the validation related codes from 3 different books along with differerent websites so far, but ONLY, if I understood it. However, there are only couple things that's beyond me, which can be seen from the comment around the code that I didn't understand i.e. comment typed after "//" Much of the code is still missing bearing in mind my expectation from this form and my lack of knowledge in how to go about doing it. This is what I'm aiming for: >> Users MUST fill in all the fields (including radio button field and drop-down menu field) >> If they don't then they should get a message saying so >> If they don't fill any certain field then they should get a message saying "Please fill in your E-mail" (for example) OR if they don't select appropriate "radio button" option or "drop-down" menu option then they should get an error message saying "please select the appropriate "Title" from the drop-down list", etc. OR "please choose the means of contacting you" (by choosing appropriate radio button) >> The "blanked" or "incorrect data entry" field should turn to "red" making it easier for user to realise what's missing >> After user fills everything & when they click "Preview" they should get some sort of "message" (ONLY if the data is valid and ALL required fields filled) saying "Following are the details you filled in" and then underneath it, CONFIRM their title, name, e-mail, telephone number, message, ways of contacting back to them, etc. (basically, ALL the field) with "Submit" and "Edit" button. Selecting "Edit" will take them back to the form, with all the data they filled in STILL there (rather than making the re-type everything) >> If they simply click on submit (after filling the required & valid data) then they should get a message saying "Thanks for your message, we'll be in touch shortly". The codes that I've created as yet are as follows:
|
|
|
|
#2
|
|||
|
|||
|
Re: PHP Form Validation ???
James, you're headed down a coding style that's going to give you an awful lot of code that will be hard to enhance and maintain in the future; I would point you towards Rasmus Lerdorf's 4 layer model and a use of functions to generate each row of your form. The "stickyness" of the incorrect / previous entries, and validation, all handled in write-once functions.
Links: Source code Related articles and included files Try out the code Learn more about it -- Graham |
|
#3
|
|||
|
|||
|
Re: PHP Form Validation ???
You might also want to look at what the HTML QuickForm package that comes with PEAR can do. It will do both server and client side validation for you.
http://www.phpfreaks.com/pear_manual...quickform.html |
![]() |
| Tags |
| php, form, validation |
| Thread Tools | |
|
|
LinkBacks (?)
LinkBack to this Thread: http://webforumz.com/php-forum/6522-php-form-validation.htm
|
||||
| Posted By | For | Type | Date | |
| Incorrect data in PHP form? | This thread | Refback | Mar 28th, 2008 15:28 | |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Form validation help! | psycho wolvesbane | JavaScript Forum | 16 | Feb 12th, 2008 16:40 |
| AS Form / Validation Help | papalazarou78 | Flash & Multimedia Forum | 0 | Jul 31st, 2007 19:43 |
| Form Validation | cjrollo | Flash & Multimedia Forum | 0 | Feb 22nd, 2007 17:33 |
| Form Validation | feebee | JavaScript Forum | 1 | Aug 3rd, 2006 16:12 |
| PHP Form Validation. | kaz | PHP Forum | 2 | Jul 22nd, 2006 20:47 |