<?php $name = $_POST['name']; $email = $_POST['email']; $url = $_POST['url']; $comments = $_POST['comments']; $recipient = "antoniomartinez@an-tonemedia.com"; $subject = "Site Submission"; $message = "E-mail: $email \n"; $message .= "URL: $url \n"; $message .= "Comments: $comments \n\n"; $headers = "From: My Form \n"; $headers .= "Reply-To: $email"; mail($recipient,$subject,$message,$headers); ?>
the process form
Started by AnTone Media, Aug 15 2006 08:42 PM
2 replies to this topic
#1
Posted 15 August 2006 - 08:42 PM
I have a form setup in PHP and was wondering how to get the process page to send me back to... well anypage on my site. here's the code I have.
#2
Posted 15 August 2006 - 08:57 PM
try this:
by adding an if statement around the mail function, it allows you to both check if it sends, and as you wanted, redirect to a new page when sent.
Redirect line:
If you wanted it without the delay, use:
Hope thats what you need.
Matt.
<?php
ob_start(); // output buffering as we modify headers later on
$name = $_POST['name'];
$email = $_POST['email'];
$url = $_POST['url'];
$comments = $_POST['comments'];
$recipient = "antoniomartinez@an-tonemedia.com";
$subject = "Site Submission";
$message = "E-mail: $email \n";
$message .= "URL: $url \n";
$message .= "Comments: $comments \n\n";
$headers = "From: My Form \n";
$headers .= "Reply-To: $email";
if( mail($recipient,$subject,$message,$headers) )
{
echo 'Message sent to: '. $recipient . ', redirecting...';
header("Refresh: 2; URL=page.php");
}
else
{
echo 'Error, message not sent.';
}
?>
by adding an if statement around the mail function, it allows you to both check if it sends, and as you wanted, redirect to a new page when sent.
Redirect line:
header("Refresh: 2; URL=page.php");
If you wanted it without the delay, use:
header("Location: url.php");
Hope thats what you need.
Matt.
#3
Posted 16 August 2006 - 12:09 AM
SWEEEEEEEEEEEEEEEEEEEEEEEEEEEET it works
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
