Mhang Posted August 17, 2010 Share Posted August 17, 2010 Ubuntu PHP Mysql So I got this form validator script online and I applied the validator part of it to my own form. My form requires a NAME and a SERIAL to be inputted and the SERIAL must be all numbers. I tested the validator by leaving NAME blank in my form and SERIAL all letters. The dispalyed resutls show the correct error messages: "Name : Please fill in a name for this computer." and "Serial : Please fill in a serial number for this computer." But the entry is still submitted with the errors and all. Here is my validator script. It begins by calling the script I got online which is from this website: http://www.html-form-guide.com/php-form/php-form-validation.html <?PHP require_once "formvalidator.php"; $validator = new FormValidator(); $validator->addValidation("Name","req","Please fill in a name for this computer."): $validator->addValidation("Serial","req","Please fill in a serial number for this computer"); $validator->addValidation("Serial","num","Serial number must be only numeric values"); if($validator->ValidateForm()) { echo "<h2>Validation Success!</h2>"; } else { echo "<B>Validation Errors:</B>"; $error_hash = $validator->GetErrors(); foreach($error_hash as $inpname => $inp_err) { echo "<p>$inpname : $inp_err</p>\n"; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/210990-form-validator-still-submiting-entries-with-errors/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 17, 2010 Share Posted August 17, 2010 But the entry is still submitted with the errors and all. Since you didn't show the compete code showing where you are using the submitted information, it will be a little hard for anyone to tell you what you did wrong. If you put your code in the if(){} logic where the echo "<h2>Validation Success!</h2>"; is at, it should have worked correctly. Quote Link to comment https://forums.phpfreaks.com/topic/210990-form-validator-still-submiting-entries-with-errors/#findComment-1100453 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.