0

Hi,

Below code gives me this error: "syntax error, unexpected" in line 5

<?php
$to = "safiullah12@hotmail.com";
$subject = "test fname, email,phone,nn";
$Sender = $_POST["email"];
$message = Name: echo $_POST["fname"] . "\r\n". ///////////////////////line 5
Email Address: <?php echo $_POST["email"] . ?> "\r\n".
Phone No: echo $_POST["phone"] . "\r\n" ;
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

$headers = "From: ".$Sender . "\r\n" .
'Reply-To: '.$Sender. "\r\n".
'X-Mailer: PHP/' . phpversion();

mail($to,$subject,$message);
?>


pls advise.
Thx.

4
Contributors
4
Replies
7
Views
6 Years
Discussion Span
Last Post by 84hd0ns
0

Hi,

Below code gives me this error: "syntax error, unexpected" in line 5

<?php
$to = "safiullah12@hotmail.com";
$subject = "test fname, email,phone,nn";
$Sender = $_POST["email"];
$message = Name: echo $_POST["fname"] . "\r\n". ///////////////////////line 5
Email Address: <?php echo $_POST["email"] . ?> "\r\n".
Phone No: echo $_POST["phone"] . "\r\n" ;
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

$headers = "From: ".$Sender . "\r\n" .
'Reply-To: '.$Sender. "\r\n".
'X-Mailer: PHP/' . phpversion();

mail($to,$subject,$message);
?>


pls advise.
Thx.

I can't say for sure, but I believe that you need to use single quotes inside the instead of the double quotes.

Edited by showman13: n/a

0

Your code is a syntactical nightmare.
Strings in PHP have to be enclosed in single or double quotes. ($message = Name)
You cannot open a <?php tag inside an already opened one.
A tip: do not mix HTML and PHP code. Write code like yours this as pure PHP without ever closing the PHP bracket.

0

Hello,

This might work:

<?php 
$to = "safiullah12@hotmail.com";
$subject = "test fname, email,phone,nn";
$Sender = $_POST["email"];
$message = " Name: ".$_POST['fname']."\r\n <br /> Email Address: ".$_POST['email']."\r\n <br /> Phone No: ".$_POST["phone"]."\r\n";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0 \r\n Content-type:text/html;charset=iso-8859-1 \r\n From: ".$Sender."\r\n Reply-To: ".

mail($to,$subject,$message,$headers);
?>

I added <br/> because if you're sending as html you will need it.

Calum

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.