PHP mail form subject line
Posted: Wed Dec 10, 2003 6:06 pm
Here's my problem.
I need to have it so that what ever is selected in the selection box will appear in the subject line of my email form. If someone can suggest the code for this, it'd be appreciated. here's my code:
<?php
//This is the location of your sendmail variable
//if you don't know, contact your sysadmin
$mail_path = "/usr/sbin/sendmail -t -i";
//The email address to be receiving emails from this form
$mail_to = "shaun@256fxdesigns.ca, crap@256fxdesigns.ca";
//the subject of the email sent by the form
$mail_subject = "Comments";
//the name of the buisness or website that the form contacts
$buisness_name = "Stop and Save Liquidation Surplus Sales";
//this is the html of the form used to create the email
$form_html = '$html = "
<form action=\"$PHP_SELF\" method=\"post\">
<table class=\"mainText\" border=\"1\" align=\"center\" bordercolor=\"0099ff\" cellspacing=\"5\">
<tr>
<td>Full Name: </td>
<td>$name</td>
</tr>
<tr>
<td>Home Phone: </td>
<td>$home</td>
</tr>
<tr>
<td>Work/Cell Phone: </td>
<td>$work</td>
</tr>
<tr>
<td>Email: </td>
<td>$reply<td>
</tr>
<tr>
<td>Inquiry: </td>
<td>$inquiry</td>
</tr>
<tr>
<td colspan=\"2\" align=\"center\">Comments</td>
</tr>
<tr>
<td colspan=\"2\" align=\"center\">$message</td>
</tr>
<tr>
<td colspan=\"2\" align=\"center\">$send</td>
</tr>
</table>
</form>
";';
ini_set("sendmail_from", $mail_from);
ini_set("sendmail_path", $mail_path);
if ($_POST)
{
if($_POST['userEmail'])
{
if( mail($mail_to,$mail_subject, "\t From: ".$_POST['userName']."\n \t Home Phone: ".$_POST['userHome']."\n \t Work or Cell Phone: ".$_POST['userWork']."\n \t Email: ".$_POST['userEmail']."\n \t Inquiry: ".$_POST['userInquiry']."\n\n\n". stripslashes($_POST['userMessage']), "From: $_POST[userEmail]\r\n"
."Reply-To: $_POST[userEmail]\r\n") )
{
$html = 'Thank you for contacting '.$buisness_name.', '.$_POST['userName'].'. <br/>Your email was sent <br/>';
}
else
{
$html = 'There was an error';
}
}
}
else
{
$message = '<textarea name="userMessage" rows="10" cols="30"></textarea>';
$name = '<input type="text" name="userName" size="30">';
$home = '<input type="text" name="userHome" size="30">';
$work = '<input type="text" name="userWork" size="30">';
$reply = '<input type="text" name="userEmail" size="30">';
$inquiry = '<select name="userInquiry" size="1">
<option selected>General Inquiries</option>
<option>Franchise Purchasing</option>
<option>Product Information</option>
<option>Store Information</option>
<option>Ebay Help</option></select>';
$send = '<input type="submit" name="submit" value="Send">';
eval($form_html);
}
?>
Thank you in advance.
shaun mckinnon
I need to have it so that what ever is selected in the selection box will appear in the subject line of my email form. If someone can suggest the code for this, it'd be appreciated. here's my code:
<?php
//This is the location of your sendmail variable
//if you don't know, contact your sysadmin
$mail_path = "/usr/sbin/sendmail -t -i";
//The email address to be receiving emails from this form
$mail_to = "shaun@256fxdesigns.ca, crap@256fxdesigns.ca";
//the subject of the email sent by the form
$mail_subject = "Comments";
//the name of the buisness or website that the form contacts
$buisness_name = "Stop and Save Liquidation Surplus Sales";
//this is the html of the form used to create the email
$form_html = '$html = "
<form action=\"$PHP_SELF\" method=\"post\">
<table class=\"mainText\" border=\"1\" align=\"center\" bordercolor=\"0099ff\" cellspacing=\"5\">
<tr>
<td>Full Name: </td>
<td>$name</td>
</tr>
<tr>
<td>Home Phone: </td>
<td>$home</td>
</tr>
<tr>
<td>Work/Cell Phone: </td>
<td>$work</td>
</tr>
<tr>
<td>Email: </td>
<td>$reply<td>
</tr>
<tr>
<td>Inquiry: </td>
<td>$inquiry</td>
</tr>
<tr>
<td colspan=\"2\" align=\"center\">Comments</td>
</tr>
<tr>
<td colspan=\"2\" align=\"center\">$message</td>
</tr>
<tr>
<td colspan=\"2\" align=\"center\">$send</td>
</tr>
</table>
</form>
";';
ini_set("sendmail_from", $mail_from);
ini_set("sendmail_path", $mail_path);
if ($_POST)
{
if($_POST['userEmail'])
{
if( mail($mail_to,$mail_subject, "\t From: ".$_POST['userName']."\n \t Home Phone: ".$_POST['userHome']."\n \t Work or Cell Phone: ".$_POST['userWork']."\n \t Email: ".$_POST['userEmail']."\n \t Inquiry: ".$_POST['userInquiry']."\n\n\n". stripslashes($_POST['userMessage']), "From: $_POST[userEmail]\r\n"
."Reply-To: $_POST[userEmail]\r\n") )
{
$html = 'Thank you for contacting '.$buisness_name.', '.$_POST['userName'].'. <br/>Your email was sent <br/>';
}
else
{
$html = 'There was an error';
}
}
}
else
{
$message = '<textarea name="userMessage" rows="10" cols="30"></textarea>';
$name = '<input type="text" name="userName" size="30">';
$home = '<input type="text" name="userHome" size="30">';
$work = '<input type="text" name="userWork" size="30">';
$reply = '<input type="text" name="userEmail" size="30">';
$inquiry = '<select name="userInquiry" size="1">
<option selected>General Inquiries</option>
<option>Franchise Purchasing</option>
<option>Product Information</option>
<option>Store Information</option>
<option>Ebay Help</option></select>';
$send = '<input type="submit" name="submit" value="Send">';
eval($form_html);
}
?>
Thank you in advance.
shaun mckinnon