Jump to content

Form submit to itself on error


monkeybidz

Recommended Posts

This form posts an error message to itself  along with the original form if error is present on a page named quote.php.

If errors are not present, the form will continue to the next page. The problem is, when i do get an error and make the correction, the form error is still there, how can i unset the error upon submiting?

 

$recto is the form action value or:

 

<form name="form1" method="post" action="<? echo "$recto";?>">
<input name="zip1" type="text" id="zip1">
<input type="submit" name="Submit" value="Continue">
</form>

 

Here is the form checking code i made:

What am i doing very wrong?

<?

$arrErrors = array("01"=>"Origin Zip Code Missing!");

if (!empty($_POST['Submit'])) {

if ($_POST['zip1']==''|| $_POST['zip1'] == false)
       $arrErrors['01'] = 'Enter a valid USA Zip Code for your origin.';
if (count($arrErrors) == 0) {
   $recto = "quote1.php";
}else{
    $strError = '<div class="formerror"><p><img src="/images/stop_sign.jpg" width="16" height="16" hspace="5" alt="">Please check the following and try again:</p><ul>';
    $recto = "quote.php";

foreach ($arrErrors as $error) {
           $strError .= "<li>$error</li>";
       }
       $strError .= '</ul></div>';
 }
}
?>

Link to comment
https://forums.phpfreaks.com/topic/56295-form-submit-to-itself-on-error/
Share on other sites

if thats input validation and the validation will take place at the same page use php self

then if the errors is fount do the echo thing and if theres no error the use the header file thing

 

hope that helps am i on the right track in not tell me comment pls

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.