Welcome to WebmasterWorld Guest from 23.22.182.29

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP email problems!

want to parse variables into html email

     
4:13 pm on Aug 20, 2004 (gmt 0)

New User

10+ Year Member

joined:Dec 1, 2003
posts:13
votes: 0


Hi there i am attempting to set up a form using php and have an autoresponding page that will include the customers name and details that they have just entered.

But i do not know the correct php setup for this to work everything is going smooth except for the $name and $clubname variables that do not appear when the email is sent.

The code is below and i would much appreciate any help on this topic.

I have marked the part i need help with (((((LIKE THIS)))))) >>>>>>>$what<<<<<<<

Thanks Guys.

<? 
// THIS IS THE BEGINNING OF THE PHP CODE
$clubname = @$HTTP_POST_VARS['orgname'];
$clubaddress = @$HTTP_POST_VARS['orgaddress'];
$seniors = @$HTTP_POST_VARS['employees'];
$juniors = @$HTTP_POST_VARS['members'];
$role = @$HTTP_POST_VARS['role'];
$name = @$HTTP_POST_VARS['name'];
$state = @$HTTP_POST_VARS['state'];
$city = @$HTTP_POST_VARS['city'];
$phone = @$HTTP_POST_VARS['phone'];
$email = @$HTTP_POST_VARS['email'];
$error_msg="";
$msg="";
if(!$name) $error_msg .= "Your name \n";
if($name) $msg .= "Your Name: \t $name \n";
if(!$phone) $error_msg .= "Your phone number \n";
if($phone) $msg .= "Phone: \t $phone \n";
if(!$email) $error_msg .= "Your email\n";
if($email){
if(!eregi("^[a-z0-9._]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$", $email)){
echo 'That is not a valid email address.';
exit;
} else {
$msg .= "Email: \t $email \n";
}
if(!$clubname) $error_msg .= "Your Organisation/Social Club's Name \n";
if($clubname) $msg .= "Organisation/Social Club Name: \t $orgname \n";
if(!$clubaddress) $error_msg .= "Your Organisation/Social Club's address \n";
if($clubaddress) $msg .= "Organisation/Social Club Address: \t $clubaddress \n";
if(!$city) $error_msg .= "Your Organisation/Social Club's City \n";
if($city) $msg .= "City: \t $city \n";
if(!$state) $error_msg .= "Your Organisation/Social Club's State \n";
if($state) $msg .= "State: \t $state \n";
if($seniors) $msg .= "Employees: \t $employees \n";
if($juniors) $msg .= "Members: \t $members \n";
if(!$role) $error_msg .= "Your Role \n";
if($role) $msg .= "Role: \t $role \n";

$sender_email="";
if(!isset($name)){
if($name==""){
$sender_name="Web Customer";
}
}else{
$sender_name=$name;
}
if(!isset($email)){
if($email==""){
$sender_email="Customer@website.com";
}
}else{
$sender_email=$email;
}
if($error_msg!= ""){
echo"You didn't fill in these required fields:<br>" . nl2br($error_msg);
exit;
}
echo " <br><h2>Thank you for your feedback $name</h2>";

/* recipients */
$to = "me@example.net.au" . ", " ; // note the comma
$to .= "$email";

/* subject */
$subject = "Welcome to example";

/* message */
$message = '

<modnote: stripped static html from here - jatar_k>

<p><strong><span class="style27"><span class="style31">CONGRATULATIONS!<br>
<br>
</span></span></strong><span class="style26"><strong><font size="2">((((((((WHAT DO I PUT HERE)))))))) >>>>>>$name<<<<<<<<<< of $clubname has been registered as Entry
Number (Entry Number) in the competition to win $1500 worth of clothing
&amp; promotional products drawn on the 31 st of December 2004. $clubname will be advised by email to $email
of the winner by no later than the 7 th of January 2005</font></strong></span><font size="2"><strong><span class="style17">.</span>
<br>
</strong></font><strong><span class="style27"><span class="style19"><font size="1">If
any information shown is incorrect, please (click here) to advise us
of any changes.</font></span></span></strong>
<p><strong><span class="style18"><font size="+2">GOOD LUCK!</font> </span></strong>
<h2 class="style20"><span class="style27">PRINT OUT THIS EMAIL</span>
</h2>
<p class="style20"><strong><span class="style18"><font size="+2">THIS
EMAIL IS WORTH CASH!</font></span></strong> </p>
<p align="center" class="style27"><span class="style28"><span class="style29"><font size="2"><strong>Keep
this print out</strong> along with any other entries from (Organisation
or Club Name) to use within 12 months of the date of this email. Maximum
redeemable value for </font></span><span class="style28"><span class="style29"><font size="2">(Organisation
or Club Name) </font></span></span><span class="style29"><font size="2">is
$25 for 25 entries.</font></span></span></p>
<p align="center" class="style27"><span class="style22">How Can
(Organisation or Social Club Name)Further Benefit?</span></p>
</div>
<ul>

<modnote: stripped static html from here - jatar_k>

</html>
';

/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

/* additional headers */
$headers .= "To: Rudy <me@example.net.au>\r\n";
$headers .= "From: example <me@example.com>\r\n";
$headers .= "";
$headers .= "";
/* and now mail it */
mail($to, $subject, $message, $headers);
//THIS IS THE END OF THE PHP CODE?>

Sorry i know that is a lot of code but i didnt know if i could shorten it or not and yes the html is bad! but this is a friends work and he wants me to fix it and time is of the essence!

If anyone could help me out it would be great!

Thanks again.

[edited by: jatar_k at 4:49 pm (utc) on Aug. 20, 2004]
[edit reason] heavily edited code [/edit]

4:59 pm on Aug 20, 2004 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 13, 2003
posts:775
votes: 0


Hi Oslo2004,

You've got single quotes around your message variable which means it won't be parsed for variables. Many things you can do but at this point I'd concatenate all your variables.

$message = '
<p><strong><span class="style27"><span class="style31">CONGRATULATIONS!<br>
<br>
</span></span></strong><span class="style26"><strong><font size="2">' . $name . ' of ' . $clubname . ' has been registered as Entry
Number (Entry Number) in the competition to win $1500 worth of clothing
&amp; promotional products drawn on the 31 st of December 2004. ' . $clubname . ' will be advised by email to ' . $email . '... and so on and so on

5:49 pm on Aug 20, 2004 (gmt 0)

New User

10+ Year Member

joined:Dec 1, 2003
posts:13
votes: 0


Thanks so much for that it worked treat!

Cheers
Enrico