Forum Moderators: coopster
$to = "me@example.com";
$from = $_POST["name"];
$subject = "mysubject";
$reason = $_POST["reason"];
$email = $_POST["email"];
$phone = $_POST["phone"];
if ($_POST["method"] == "email")
{
$prefer = "email";
}
else
{
if ($_POST["method" == "phone"])
{
$prefer = "phone";
}
else
{
$prefer = "no preference";
}
}
$comments = $_POST["comments"];
$text = "<html><body><p>";
$text .= "From: " . $from . "<br />";
$text .= "Reason: " . $reason . "<br />";
$text .= "E-mail address: " . $email . "<br />";
$text .= "Phone: " . $phone . "<br />";
$text .= "Preferred method of contact: " . $prefer . "<br />";
$text .= "Comments: " . $comments;
$text .= "</p></body></html>";
$header .= 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$header .= "From: me@example.com" . "\r\n";
$header .= "Reply-To: $email";
if ($name == "" &&($email == "" && $phone == ""))
{
$msg = "<p>Name and contact fields are required. Your information was not submitted.<br>Please try again.</p><p><a href='contact.php'>Back to form</a></p>";
}
else
{
if (mail($to,$subject,$text,$header))
{
$msg = "<p style='text-align: center; height: 350px;'>Thank you for your submission. Someone will contact you shortly.</p>";
} [edited by: coopster at 6:45 pm (utc) on Feb 20, 2013]
[edit reason] fixed a typo [/edit]
$header = 'From: Adventure Ropes Course' . "\r\n" . 'Reply-To: $email' . "\r\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-type: text/html; charset=iso-8859-1";
$header = 'From: Adventure Ropes Course' . "\r\n" . 'Reply-To: $email' . "\r\n";
$header .= "MIME-Version: 1.0\n"; [edited by: tedster at 8:02 pm (utc) on Feb 19, 2013]
[edit reason] switch URL to example.com [/edit]