Jump to content

Self Submitting Form


misslilbit02

Recommended Posts

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<<

?>

 

Link to comment
https://forums.phpfreaks.com/topic/54577-self-submitting-form/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.