Good day

I want to write multiple response to my email, I get line 7

Please can anyone help please;

My code

<?php
$to = "info@apps4u.co.za"; 
$subject = "Contact Us"; 
$email = $_REQUEST['email'] ;

$q1 = "Feed back text:\n";
$q1 .= "$_REQUEST['text']\n" ;
$q2 = "Who sent you:";
$q2 .= "$_REQUEST['whosentyou']\n" ;

$name = $_REQUEST['name'] ;
$headers = "From: $name <$email>";
$whosentyou = $_REQUEST['whosentyou'] ;
$message = $q1 . "\n". $q2; 
$sent = mail($to, $subject, $message, $headers) ; 
if($sent) 
{print "Your mail was sent successfully"; }
else 
{print "We encountered an error sending your mail"; }
?>

The error

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Domains\apps4u.co.za\wwwroot\ServecisRequest.php on line 7

Thanks

PHP does not like array values inside of strings ...
You can do several things here. Replace $q1 .= "$_REQUEST\n" ; with ...

$q1 .= "{$_REQUEST['text']}\n"
// ... or ...
$q1 .= $_REQUEST['text']."\n";

Hope this helps

Thanks I will try this and get back to you.
Thank you

try this it will work

<?php
$to = "info@apps4u.co.za"; 
$subject = "Contact Us"; 
$email = $_REQUEST['email'] ;

$q1 = "Feed back text:\n";
$q1 .= $_REQUEST['text'] ."<br />" ;
$q2 = "Who sent you:";
$q2 .= $_REQUEST['whosentyou']."<br />" ;
$name = $_REQUEST['name'] ;
$headers = "From:". $name ."<".$email.">";
$whosentyou = $_REQUEST['whosentyou'] ;
$message = $q1 . "\n". $q2; 
$sent = mail($to, $subject, $message, $headers) ; 
if($sent) 
{print "Your mail was sent successfully"; }
else 
{print "We encountered an error sending your mail"; }
?>
This article has been dead for over six months. Start a new discussion instead.