
Rusty Watson - 2010-10-19 14:42:45
Hi, I am new for the PHP email form. I had been trying to learn how to use the PHP email from scripts over different places in the internet. I was very interesting to learn how to create the PHP custom email form like "contact us", "tell a friend", etc.
One problem, I had problem to understand in PHP email form script as "email($toEmail, $subject, $message, $from)”. I wanted to add $message2 or $body into “email($toEmail, $subject, $message, $from)”. It didn't work with $message2 or $body. What did I miss? I thought it is very simple to add?
Here's 2 email form scripts below...
Original script before adding “$message2”: (it is working fine)
<?php
$fromName=$_REQUEST["fromName"];
$fromEmail=$_REQUEST["fromEmail"];
$toName=$_REQUEST["toName"];
$toEmail=$_REQUEST["toEmail"];
if ($fromEmail)
{
$ref=getenv('HTTP_REFERER');
$fromEmail= stripcslashes($fromEmail);
$fromName= stripcslashes($fromName);
$toEmail= stripcslashes($toEmail);
$toName= stripcslashes($toName);
$message= stripcslashes($message);
if ($fromName=='')
$subject= "Your friend has referred you this link from www.sitename.com";
else
$subject= "$fromName has referred you this link from www.sitename.com";
$message = "
Dear $toName,
Your friend $fromName has referred this link to you.
Please visit this link by clicking $ref
";
$from = "From: $fromEmail\r\n";
mail($toEmail, $subject, $body, $message, $from);
$sent = "your message has been sent";
}
?>
Added $message2 in email script below:
<?php
$fromName=$_REQUEST["fromName"];
$fromEmail=$_REQUEST["fromEmail"];
$toName=$_REQUEST["toName"];
$toEmail=$_REQUEST["toEmail"];
if ($fromEmail)
{
$ref=getenv('HTTP_REFERER');
$fromEmail= stripcslashes($fromEmail);
$fromName= stripcslashes($fromName);
$toEmail= stripcslashes($toEmail);
$toName= stripcslashes($toName);
$message= stripcslashes($message);
$message2= stripcslashes ($message2);
if ($fromName=='')
$subject= "Your friend has referred you this link from $ref";
else
$subject= "$fromName has referred you this link from $ref";
$message = "
Dear $toName,
Your friend $fromName has referred this link to you.
Please visit this link by clicking $ref
";
$message2 = "
Hope you have a nice day!
";
$from = "From: $fromEmail\r\n";
mail($toEmail, $subject, $message, $message2, $from);
$sent = "your message has been sent";
}
?>
Can you please tell me what did I miss or overlook the script? I am trying to learn. Thank you for help very much. Rusty