Jump to content

Email Script


austin350s10

Recommended Posts

Ok...so my problem is that my email script has a small problem with it.  I designed my script so it will send the person completing the form a confirmation email in html format. 

 

The only problem is that when I try to put two variables side by side they will not show up on the confirmation email.  But when i put one variable per line of html code the confirmation email looks fine.  Example $Fname $Lname will not show on the confirmation email.  Do i need some kind of separator to distinguish the to variables?

 

Here is my code:

<?php



/*subject and email variables*/ 
$emailSubject = 'Survivor or Care Provider Registration';

/*gathering data variables*/
$FnameField = $_POST['Fname'];
$LnameField = $_POST['Lname'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$attendField = $_POST['attend'];
$numberField = $_POST['number'];
$transField = $_POST['trans'];
$attend = implode(', ', $attendField);
$trans = implode(', ', $transField);

/*email field*/

$body = <<<EOD
<br><hr><br>
<h2>Registration Confirmation Email</h2>
<hr>
Name Registered: $Fname $Lname <br> \\<=== This is where my problem is...it will not show $Fname or $Lname on email	
Email Address: $email <br>   \\<=== All fields that have one variable like this one view fine on email
Phone Number: $phone <br>
Attending As: $attend <br>
Bringing $number including $Fname $Lname <br>
Will $Fname $Lname need transportation: $trans<br>
<br>
Thank you for registering!<br> 
EOD;

/*email sender script*/
$sendto = $_POST['email'];
$headers = "From: [email protected]\r\n";
$headers .= "Bcc: [email protected]\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($sendto, $emailSubject, $body, $headers);

/*resultes*/
$theResults = <<<EOD
<html>
<body>
<h1>Thank You</h1>
</body>
</html>
EOD;
echo "$theResults";

?>

 

This layout produces an email that looks like this:

 

Registration Confirmation Email

 

Name Registered: (should be first & last name but nothing)

Email Address: ($email value form script)

Phone Number: ($phone value form script)

Attending As: ($attend value form script)

Bringing (should $number but nothing) including (should be $Fname $Lname name but nothing)

Will (should be $Fname $Lname but nothing) need transportation: (should be $trans but nothing)

 

Thank you for registering!

 

 

 

Any ideas????

Link to comment
https://forums.phpfreaks.com/topic/185118-email-script/
Share on other sites

<?php/*subject and email variables*/ 	$emailSubject = 'Survivor or Care Provider Registration';/*gathering data variables*/	$FnameField = $_POST['Fname'];	$LnameField = $_POST['Lname'];	$email = $_POST['email'];	$phone = $_POST['phone'];	$attendField = $_POST['attend'];	$numberField = $_POST['number'];	$transField = $_POST['trans'];	$attend = implode(', ', $attendField);	$trans = implode(', ', $transField);	/*email field*/	$body = <<<EOD<br><hr><br><h2>Registration Confirmation Email</h2><hr>Name Registered: $FnameField $LnameField <br> 	Email Address: $email <br>  Phone Number: $phone <br>Attending As: $attend <br>Bringing $number including $Fname $Lname <br>Will $Fname $Lname need transportation: $trans<br><br>Thank you for registering!<br> EOD;/*email sender script*/	$sendto = $_POST['email'];	$headers = "From: [email protected]\r\n";	$headers .= "Bcc: [email protected]\r\n";	$headers .= "Content-type: text/html\r\n";	$success = mail($sendto, $emailSubject, $body, $headers);	/*resultes*/	$theResults = <<<EOD<html><body><h1>Thank You</h1></body></html>EOD;echo "$theResults";?>

 

Use the above code, it will indeed fix your problem. Also note to always 'double-check' your variables when outputing them onto an e-mail message.. simple mistakes like that can cause it to not work.

Link to comment
https://forums.phpfreaks.com/topic/185118-email-script/#findComment-977205
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.