I have started learning PHP which I have used sporadically for the last few months.
I have been writing a mail() script but I am having a weird issue with variables within the script.
If I echo the values that are passed via $_POST the variables come out fine. For example $email simply echo's "firstname.lastname@example.org".
However, when I use this variable within my $message it remains blank upon the sending of the e-mail. I just can't figure out why! Ignore the email@example.com as this is just an example. I also realise this doesn't protect me against attacks but that is something I'm going to read up on next once I have this working.
Code: Select all
$name = $_POST['yourname'];
$phone_number = $_POST['phonenumber'];
$email = $_POST['emailaddress'];
$to = "firstname.lastname@example.org";
$subject = "New submission";
$message = "Name: $name $name\r\n
Phone Number: $phone_number $phone_number\r\n
Your E-mail: $email\r\n
$additional_headers = "From: $name $name \r\n
<Reply-To: email@example.com> \r\n
X-Mailer: PHP/" . phpversion();
mail($to , $subject , $message , $additional_headers);
Thanks for your help guys