I have a basic contact script (included below). It redirects to a thankyou.html page using the header redirect which is easy, but I want it to also redirect to an error.html if theres an error. Anyone know how I can do this?
Thanks
[CODE]<?php
include(“global.inc.php”);
$errors=0;
$error=”The following errors occured while processing your form input.<ul>”;
pt_register(‘POST’,’Date’);
pt_register(‘POST’,’InquiryType’);
pt_register(‘POST’,’Status’);
pt_register(‘POST’,’HowDidYouHearAboutUs’);
pt_register(‘POST’,’FirstName’);
pt_register(‘POST’,’LastName’);
pt_register(‘POST’,’WorkTel’);
pt_register(‘POST’,’MobileTel’);
pt_register(‘POST’,’HomeTel’);
pt_register(‘POST’,’EmailAddress’);
pt_register(‘POST’,’StreetAddress’);
pt_register(‘POST’,’AptSuite’);
pt_register(‘POST’,’City’);
pt_register(‘POST’,’State’);
pt_register(‘POST’,’ZipCode’);
pt_register(‘POST’,’PropertyType’);
pt_register(‘POST’,’PurchasePrice’);
pt_register(‘POST’,’WhatStateIsThePropertyIn’);
pt_register(‘POST’,’RankYourCredit’);
pt_register(‘POST’,’DesiredDocumentation’);
pt_register(‘POST’,’Message’);
$Message=preg_replace(“/( 15 12)|( 15)|( 12)/”,” <br />”, $Message);pt_register(‘POST’,’Agreement’);
pt_register(‘POST’,’AgreementText’);
if($InquiryType==”” || $FirstName==”” || $LastName==”” || $HomeTel==”” || $EmailAddress==”” || $State==”” || $PropertyType==”” || $WhatStateIsThePropertyIn==”” || $RankYourCredit==”” || $DesiredDocumentation==”” || $Agreement==”” ){
$errors=1;
$error.=”<li>You did not enter one or more of the required fields. Please go back and try again.”;
}
if(!eregi(“^[a-z0-9]+([_\.-][a-z0-9]+)*” .”@”.”([a-z0-9]+([.-][a-z0-9]+)*)+”.”\.[a-z]{2,}”.”$”,$EmailAddress)){
$error.=”<li>Invalid email address entered”;
$errors=1;
}
if($errors==1) echo $error;
else{
$where_form_is=”http”.($HTTP_SERVER_VARS[“HTTPS”]==”on”?”s”:””).”://”.$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),”/”));
$message=”Date: “.$Date.”
Inquiry Type: “.$InquiryType.”
Status: “.$Status.”
How Did You Hear About Us: “.$HowDidYouHearAboutUs.”
First Name: “.$FirstName.”
Last Name: “.$LastName.”
Work Tel: “.$WorkTel.”
Mobile Tel: “.$MobileTel.”
Home Tel: “.$HomeTel.”
Email Address: “.$EmailAddress.”
Street Address: “.$StreetAddress.”
Apt Suite: “.$AptSuite.”
City: “.$City.”
State: “.$State.”
Zip Code: “.$ZipCode.”
Property Type: “.$PropertyType.”
Purchase Price: “.$PurchasePrice.”
What State Is The Property In: “.$WhatStateIsThePropertyIn.”
Rank Your Credit: “.$RankYourCredit.”
Desired Documentation: “.$DesiredDocumentation.”
Message: “.$Message.”
Agreement: “.$Agreement.”
Agreement Text: “.$AgreementText.”
“;
$message = stripslashes($message);
mail(“[email protected],”Form Submitted at your website”,$message,”From: contact form”);
header(“Refresh: 0;url=thankyou.html”);
?><?php
}
?>