I asked this question earlier but felt it was a little lengthy and not to the point. I am looking to add a contact to the $to =
when one select <option value="foo"
is selected out of the list of 5. I have little experience in PHP and this is a preexisting form on the site. The examples I have been looking at describe adding an array for multiple email addresses. However, I only need to add one email on one of the <option value="foo"
not all 5 of the options. Any and all help is greatly appreciated. Code is below thank you.
<?
ob_start();
if(isset($_POST['registersubmit']))
{
unset($badcaptcha);
require_once('/recaptchalib.php');
$privatekey = "...";
$resp = recaptcha_check_answer ($privatekey,$_SERVER["REMOTE_ADDR"],$_POST["recaptcha_challenge_field"],$_POST["recaptcha_response_field"]);
if (!$resp->is_valid)
{
$badcaptcha=true;
}
else
{
//Send email
//foo@test.com
$to = "foo@test.com\r\n";
$from = "test.com <contact@test.com>";
$subject = "Parts Inquiry test\r\n";
$body = "Parts Inquiry test\r\n\n";
//$body .= "Know The Part Number: ".$_POST['ToggleDivs']."\r\n\n";
if($_POST['ToggleDivs']=="yes")
{
$body .= "Qty: ".$_POST['qty1']." Parts Number: ".$_POST['parts1']."\r\n\n";
$body .= "Qty: ".$_POST['qty2']." Parts Number: ".$_POST['parts2']."\r\n\n";
$body .= "Qty: ".$_POST['qty3']." Parts Number: ".$_POST['parts3']."\r\n\n";
$body .= "Qty: ".$_POST['qty4']." Parts Number: ".$_POST['parts4']."\r\n\n";
$body .= "Qty: ".$_POST['qty5']." Parts Number: ".$_POST['parts5']."\r\n\n";
$body .= "Qty: ".$_POST['qty6']." Parts Number: ".$_POST['parts6']."\r\n\n";
$body .= "Qty: ".$_POST['qty7']." Parts Number: ".$_POST['parts7']."\r\n\n";
$body .= "Qty: ".$_POST['qty8']." Parts Number: ".$_POST['parts8']."\r\n\n";
$body .= "Qty: ".$_POST['qty9']." Parts Number: ".$_POST['parts9']."\r\n\n";
$body .= "Qty: ".$_POST['qty10']." Parts Number: ".$_POST['parts10']."\r\n\n";
}
else
{
$body .= "Make: ".$_POST['Make']."\r\n\n";
$body .= "Model: ".$_POST['model']."\r\n\n";
$body .= "VIN: ".$_POST['vin']."\r\n\n";
$body .= "Category: \r\n\n";
$body .= "*".$_POST['category1']."*".$_POST['category2']."*".$_POST['category3']."*".$_POST['category4']."*".$_POST['category5']."*".$_POST['category6']."*".$_POST['category7']."*".$_POST['category8']."*".$_POST['category9']."*".$_POST['category10']."*".$_POST['category11']."*".$_POST['category12']."*".$_POST['category13']."*".$_POST['category14']."*".$_POST['category15']."*".$_POST['category16']."*".$_POST['category17']."\r\n\n";
$body .= "Describe the part(s) you need: \r\n\n";
$body .= "".$_POST['parts_info']."\r\n\n";
}
$body .= "\r\n\n";
$body .= "##############################\r\n\n";
$body .= "Do you have an account with us? ".$_POST['acct']."\r\n\n";
if($_POST['acct']=="yes")
{
$body .= "My account number is: ".$_POST['acct_n']."\r\n\n";
/*$body .= "Do you have an account with us? ".$_POST['acct']."\r\n\n";
$body .= "If yes, this is the account number: ".$_POST['acct_n']."\r\n\n";*/
}
if($_POST['ship_opts']=="Delivery")
{
$body .= "Shipping option: ".$_POST['ship_opts']." \r\n\n";
}
else if($_POST['ship_opts']=="Other")
{
$body .= "Other shipping option selected: ".$_POST['ship_other']."\r\n\n";
}
else
{
$body .= "Will Pick Up at: ".$_POST['ship_opts']." \r\n\n";
$body .= "This is the pick up date: ".$_POST['pick_up_date']."\r\n\n";
//$body .= "Other shipping option selected: ".$_POST['ship_other']."\r\n\n";
}
$body .= "\r\n\n";
$body .= "##############################\r\n\n";
$body .= "Contact's Information:\r\n\n";
$body .= "Full Name: ".$_POST['Fname']."\r\n\n";
$body .= "Business Name: ".$_POST['Bname']."\r\n\n";
$body .= "Email: ".$_POST['email']."\r\n\n";
$body .= "Address: ".$_POST['address']."\r\n\n";
$body .= "City: ".$_POST['city']."\r\n\n";
$body .= "State: ".$_POST['state']."\r\n\n";
$body .= "Zip Code: ".$_POST['zipcode']."\r\n\n";
$body .= "Phone: ".$_POST['phone']."\r\n\n";
$body .= "Location: ".$_POST['location']."\r\n\n";
$body .= "Comments/Message: ".$_POST['details']."\r\n\n";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
mail($to, $subject, $body, "From: ".$from."\r\n".$headers);
//Send copy omega@test.com
$to = "omega@test.com\r\n";
mail($to, $subject, $body, "From: ".$from."\r\n".$headers);
$to = "alpha@test.com\r\n";
mail($to, $subject, $body, "From: ".$from."\r\n".$headers);
$to = "beta@test.com\r\n";
mail($to, $subject, $body, "From: ".$from."\r\n".$headers);
if ($_POST['ship_opts'] == 'foo') {
$to = "foo@test.com\r\n";
mail($to, $subject, $body, "From: ".$from."\r\n".$headers);
}
header("Location:thankyou_contact2.php");
}
}
$linkname="parts1";
if(empty($id)) { $id = 23; $showplus = "Y"; }
include("includes/header.php");
?>
HTML below;
<div id="pick_up" style="display: none;position:relative;">
<label style="clear:both;"> Do you plan to pick up at one of our locations or have it delivered?<br />
<select name="ship_opts" id="ship_opts" onchange="Toggle3(this.value);">
<option value="">Make a Selection</option>
<option value="PU_C">Pick-Up C</option>
<option value="PU_D">Pick-Up D</option>
<option value="Delivery">Delivery</option>
<option value="foo">Foo</option>
</select>
</label>
</div>