Jump to content

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

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.