Sendmail.php Missing something simple I know it

Hey all,

I am trying to get my sendmail.php to send the name and phone number also but its just sending the comments… I know its something super simple I am missing. Can someone please look and let me know what it is.

Any help would be appreciated.

<?php
$to = "me@myemail.com";
$subject = "Contact Us Form";
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$phone = $_REQUEST['phone'] ;
$comments = $_REQUEST['comments'] ;
$headers = "From: $email";
$sent = mail($to, $subject, $name, $phone, $comments, $headers) ;
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
?>

I would like it to be like this, but not sure how the html would look.

<?php
 
$yourname = $_POST['yourname'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$comments = $_POST['comments'];
 
$mailmsg = "Users name is $yourname and phone number is $phone <br> email address :  $email <br> users msg: $comments";
 
if($_POST) {
 
print $mailmsg;
//print function will show us did we really stored values from our FORM fields or not
//mail('youremailaddress@gmail.com',"aj php form", $mailmsg);
 
}
 
?>

From php.net:


bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

Your code:


$sent = mail($to, $subject, $name, $phone, $comments, $headers) ;

See anything wrong yet?

Try:


$sent = mail($to, $subject, '$name' . "\
" . '$phone' . "\
" . $comments, $headers) ;

Thanks for the reply, When I tested the form, this is what I got in return in my email

$name
$phone
Is this working?

Ha woops. Haven’t written in PHP in a while… and I’m still tired…

$sent = mail($to, $subject, $name . "\
" . $phone . "\
" . $comments, $headers) ;

I didn’t mean to wrap the variables, that turns them into strings…

Thank you very much, that did the trick. Now go get ya some coffee…lol