Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.