/    Sign up×
Community /Pin to ProfileBookmark

php redirect in a contact script

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(“/(1512)|(15)|(12)/”,”&nbsp;<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
}
?>[/CODE]

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@jim_boNov 13.2006 — Hi,

Maybe a meta refresh within your error msq variable

[code=php]<meta http-equiv="refresh" content="3; url=form.php">';[/code]
Copy linkTweet thisAlerts:
@invisible777authorNov 13.2006 — I get a parse error whenever I stick that in one of the error tags ... unless im doing something wrong...
Copy linkTweet thisAlerts:
@NogDogNov 13.2006 — [code=php]
if($errors)
{
header("Location: http://www.yoursite.com/error_page.html");
}
else
{
// ... etc. ...
[/code]
×

Success!

Help @invisible777 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...