In the preceding screen you clearly see that even I have wriiten the code on the create button to redirect to the next page but it will not be redirected because the form data is blank and it does not satisfy our validation condition that we set.
In other words, it's clear that the validation is done at the client side in the browser level and only validates the data; it will execute the server-side code.
Such code can now do no harm and is safe to be displayed on a page or inside an e-mail. if quotes are escaped with a slash \ let's remove that.
Sure, it may not look nice and tell you someone has been trying to mess with your script, but the important thing is he/she had failed! If you know exactly what kind of data to expect you can make further steps to ensure the user has entered what you want. Instead of writing the same code over and over again we can create a function that will do all the checking for us.
Now click on the "Create" button; it will redirect to the next page as in the following: Note For detailed code please download the zip file attached above.
It's also very precise, as you can point out the exact field where there's a problem.
We're going to be checking the form using a function, which will be activated by the form's Validating this form would be considerably simpler than one containing radio buttons or select boxes, but any form element can be accessed.
If you have any suggestion related to this article then please contact me.
When you submit a form to a CGI program that resides on the server, it is usually programmed to do its own check for errors.