![]() |
| ||
| User Form error checking Hey everyone, I need some advice. I have a simple user form. Name, email, comments, blah blah blah. Currently for error checking, in my code, if the user inputs something invalid or doesn't fill out a required field, I redirect them to another page that tells them the error, then they have to hit the back button to go back and fix it. I'd like to make this process a little easier for the user. I've seen forms where if you miss a required field or something, it simply brings the form back up and at the top in red letters will tell you to fill in all the required fields or something, and then have like a red star next to those fields. I'm sure if I sat around for a few hours I could come up with a real clunky, code-heavy way of doing this, but I was wondering if you all can give me some ideas. An easy way of doing this? I have a moderate understanding of php, so I know most of the basic functions and things. And when I come across one I don't know, I'll learn it, so bring it on. Ideas? |
| ||
| Re: User Form error checking No need to send them to another page. Data validation is easy to do. 1) Receive the POSTed form data (top of the file) 2) Validate it. Put errors into an array so you can echo them out later 3) Check to see if you found any errors. If not, do whatever you want to do with the data. 4) If there are error, redisplay the page and list the errors so the users knows what they did wrong. This method also allows you to repopulate the form fields if there is an error so they don't have to type it in again. |
| ||
| Re: User Form error checking Quote:
Thanks. |
| ||
| Re: User Form error checking Another idea is to also include a javascript validation. There are plenty of tutorials found through google. Just look up "Javascript Form Validation". That way when the button is clicked, the form is instantly checked and a message displayed at that moment without a page having to be reloaded. However, you still should included some server side validation, using php. The javascript is jut to make it easier for the person. The php is there incase the person gets around the javascript. |
| ||
| Re: User Form error checking Quote:
|
| ||
| Re: User Form error checking Quote:
http://www.securephpwiki.com/index.php/Email_Injection |
| ||
| Re: User Form error checking I guess you missed item number 2? ;) Quote:
|
| ||
| Re: User Form error checking Quote:
And FYI, your help has worked. I'm going it the way you said, submitting the form to itself, and I have a variable that is stored, that is at first set to nothing. Any errors that pop up append themselves to the variable. Then if there are errors, it shows the form with that variable at the top. Working splendidly. Thanks! |
| ||
| Re: User Form error checking Nathan - just an idea - you could display the error messages next to the wrong fields, while the correct fields data is automatically entered into the correct field, so the user does not have to fill in all the fields. Or, even better - you can show only the wrong fields, that have invalid data, instead of showing all, and still error messages to be just beside the erroneous field. |
| All times are GMT -4. The time now is 2:46 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC