954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

php mail form - need to redirect to new page

<?php
if($_POST['submitform']) {

$Name = $HTTP_POST_VARS['Name'];
$Email = $HTTP_POST_VARS['Email'];
$Comments = $HTTP_POST_VARS['Comments'];

// check required fields
$dcheck = explode(",",$require);
while(list($check) = each($dcheck)) {
if(!$$dcheck[$check]) {
$error .= "Missing $dcheck[$check]
";
}
}

// check email address
if ((!ereg(".+\@.+\..+", $Email)) || (!ereg("^[a-zA-Z0-9_@.-]+$", $Email))){
$error .= "Invalid email address
";}

// display errors
if($error) {
?>
Error

<?php echo $error; ?>
try again
<?php
}
else
{

$browser = $HTTP_USER_AGENT;
$ip = $REMOTE_ADDR;

// format message
$message = "Online-Form Response for $recipientname:

Name: $Name
Email: $Email

Comments: $Comments

-----------------------------

Browser: $browser
User IP: $ip";

// send mail and print success message
mail($recipientemail,"$subject","$message","From: $Name <$Email>");

if($autoresponse == "yes") {
$autosubject = stripslashes($autosubject);
$automessage = stripslashes($automessage);
mail($Email,"$autosubject","$automessage","From: $recipientname <$recipientemail>");
}

echo "$thanks";
}
}
else {
?>



Name



E-mail



Comments



<?php } ?>

tomeemot
Newbie Poster
1 post since May 2005
Reputation Points: 10
Solved Threads: 0
 

I believe that instead of echoing the thank you message, you can have it do a redirect instead.

Change this:
[php]echo "$thanks";[/php]

To this:
[php]header("Location: page_to_redirect_to.php");[/php]

PatrickE
Newbie Poster
9 posts since May 2005
Reputation Points: 10
Solved Threads: 0
 

You may get error message by sending header after the tag. You may want to replace the redirection header with javascript below:


zippee

-------------------------
www.basket2go.net
www.store2go.net

zippee
Posting Whiz in Training
294 posts since Jan 2005
Reputation Points: 10
Solved Threads: 7
 

Thank you, zippee, this really helped.
But I don't know how to make it redirect after displaying the page for a second.

emodweb
Newbie Poster
1 post since Nov 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You