misslilbit02 Posted June 7, 2007 Share Posted June 7, 2007 Hi I have a self submitting form and I have a function that is a called to print out errors. Some of the code in the form is below. In the function I put the errors in an array. When I submit the form only two errors are printed out at a time. I want to know why is that if I'm constantly putting my errors in an array only two errors are printed at a time. The form is processing all the errors and will not let the user submit the form with errors but it won't print out all the errors all at once. Can someone help me figure out why only two errors are printed at a time? function validate_form() { if($_POST['Submit']=="Submit") { $errors=array(); //Check for errors if(! strlen(trim($_POST['name']))) { $errors[] = "Please enter your name"; } elseif(! strlen(trim($_POST['major']))) { $errors[] = "Please enter your major"; } >>more and more error checking not included in this snippet<< return $errors; } <?php if(isset($_POST['Submit']) && $_POST['Submit']=="Submit") { $results; $results=validate_form(); if(count($results) == 0) { process_form(); } else{ for($i=0; $i<count($results); $i++) { echo "$results[$i], "; } } } >>html code for the form<< ?> Quote Link to comment https://forums.phpfreaks.com/topic/54577-self-submitting-form/ 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.