So i have created validation criteria for my web form. I have tested it to see if it catches the errors on the form. And it does. Is there an easy way to make the parser stay on the validation code until evrything is found correct. the beginning of my web form: <form method="POST" action="insert.php"> My validation code is on insert.php I tried this: if (isset($_POST['Submit'])) { //Declaring the text input fields $ULVID= $_POST['ULVID']; $FirstName= $_POST['FirstName']; $LastName= $_POST['LastName']; $Age= $_POST['Age']; // Checking to see if the required fields are empty if(empty($FirstName)) {echo'<b>You forgot to enter your First Name     Press the Back Button <br/>';} if(empty($LastName)) {echo'<b>You forgot to enter your Last Name     Press the Back Button <br/>';} if(empty($Age)) {echo'<b>You forgot to enter your Age     Press the Back Button <br/>';} if( strpos($Email, '@') === false || strpos($Email, '.') === false || strpos($Email, ' ') != false || strpos($Email, '@') > strpos($Email, '.') ) {echo '<b>Please enter a valid email address     Press the Back Button <br/>';} nl2br(strip_tags(stripslashes($Answer1))); nl2br(strip_tags(stripslashes($Answer2))); } else { $con = mysql_connect("localhost","",""); mysql_select_db("CpaApp", $con); //insert Queries Code (markup): Please Help
Just some advice just checking for @ in a email address is not proper validation. Someone could submit literally.fake*(#*(email@example.com , and that would be "valid".You'll want to use preg_match for the email validation and a good regex. Which you should find already done somewhere, no point reinventing the wheel.
There are three ways to do that: 1. Use JavaScript also to validate. Form submissions should be validated on the server side also. 2. Use Ajax and do the validations on the server side only. 3. Use Session Variables to keep the values in the form.(when the form is displayed next time)