PHP Mail

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
brmcdani44
Forum Commoner
Posts: 26
Joined: Fri Oct 08, 2010 3:52 pm

PHP Mail

Post by brmcdani44 »

I am getting an unexpected T-String error on line 12 can anyone help? I have been coding for hours now and have the code blindness! lol Thanks I will sleep much better if I get this solved tonight!

Thanks in advance

Code: Select all

<?php
if ($why == 4){
echo"Click the back button and try the question again.";
exit();
}
else{
$region = $_REQUEST['region'];
$lakename = $_REQUEST['lakename'];
$why = $_REQUEST['why'];
$body = "Region: $region
\nLake Name: $lakename";
mail("brettm938@gmail.com", "Lake Add Request", $body);
}
?>
<meta http-equiv="refresh" content="0;url=thankyou.htm">
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: PHP Mail

Post by social_experiment »

I got a mail() related error, something about a missing 'From' header no 'unexpected T-String error on line 12'
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Bind
Forum Contributor
Posts: 102
Joined: Wed Feb 03, 2010 1:22 am

Re: PHP Mail

Post by Bind »

add the missing From: header ...

Code: Select all

<?php
if ($why == 4){
echo"Click the back button and try the question again.";
exit();
}
else{

$headers = "From: email@domain.com\r\nReply-To: email@domain.com";

$region = $_REQUEST['region'];
$lakename = $_REQUEST['lakename'];
$why = $_REQUEST['why'];
$body = "Region: $region
\nLake Name: $lakename";
mail("brettm938@gmail.com", "Lake Add Request", $body,$headers);
}
?>
<meta http-equiv="refresh" content="0;url=thankyou.htm">
Post Reply