I have a form which is a order cart which sends a mail with the data. I want the mail to not include the billing address when not unchecked and therefore completed, and non selected payment options to be not included as well.
Here's a demo sample: Order Check Out
Here's the mail code which the form uses to post in a text file so it can be accessed easily:
So in short I want ONLY the payment type radio being checked to equate that data being sent in the mail. And same address for the unchecked billing info same box to trigger the billing address data being sent.
Here's a demo sample: Order Check Out
Here's the mail code which the form uses to post in a text file so it can be accessed easily:
So in short I want ONLY the payment type radio being checked to equate that data being sent in the mail. And same address for the unchecked billing info same box to trigger the billing address data being sent.
PHP Code:
<?php $deny = array("61.21.111.134", "89.149.208.14", "85.17.147.193", "206.214.146.194", "66.249.67.199");
if (in_array ($_SERVER['REMOTE_ADDR'], $deny)) {
header("location: http://www.yahoo.com");
exit();
}session_start(); ?><?php session_start();
$to="support@xyzsite.com";
//////////// Mail body for site owner
// Mail Subject
$subject = "Cart submitted by ".$_POST['txtfname']." ".$_POST['txtlname'];
$headers = "From: " . $_POST['txtemail'] . "\r\n";
$headers .= "Reply-To: ". $_POST['txtemail'] . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message='<html> <link href="http://xyzsite.com/style.css" rel="stylesheet" type="text/css" /><font family="Verdana" size="2"><table width="698" border="0" cellspacing="0" cellpadding="3" align="center" style="border:1px solid #BFBFBF; font-family: Verdana; font-size:13px" bgcolor="#FFFFFF">
<tr>
<td height="35" colspan="5">
<div align="center"> <strong style="color:#004080"> Cart Details</strong><br />
</div>
</div></td>
</tr>
<tr bgcolor="#B2B2B2">
<td width="390" bgcolor="#006699" class="lglr" style="padding-left:10px"><font color="#FFFFFF" style="font-weight:bold; font-size:13px">Product</font></td>
<td bgcolor="#006699" class="lglr" style="padding-left:10px" width="150" nowrap="nowrap"><font color="#FFFFFF" style="font-weight:bold; font-size:13px">Payment Method</font></td>
<td width="71" bgcolor="#006699" class="lglr" style="padding-left:10px"><font color="#FFFFFF" style="font-weight:bold; font-size:13px">Price</font></td>
<td width="64" bgcolor="#006699" class="lglr" style="font-size:13px"><div align="center">
<font color="#FFFFFF" style="font-weight:bold; font-size:13px">Qty</font></div></td>
<td width="65" bgcolor="#006699" class="lglr2" style="padding-left:10px"><font color="#FFFFFF" style="font-weight:bold; font-size:13px">Total</font></td>
</tr>';
for ( $counter = 1; $counter <= $_SESSION["cnt"]; $counter += 1)
{
if(($counter%2)==0)
{
$message = $message.' <tr bgcolor="#F2F2F2">';
}
else
{
$message = $message.'<tr>';
}
$message = $message.'
<td class="lglr" style="font-size:13px">'.$_SESSION["title".$counter].'</td>
<td style="font-size:13px" class="lglr">'.$_SESSION["paymentmethod".$counter].'</td>
<td style="font-size:13px" class="lglr"> $'.$_SESSION["price".$counter].'</td>
<td style="font-size:13px" class="lglr3">'.$_SESSION["qty".$counter].'</td>
<td style="font-size:13px" class="lglr2">$'.$_SESSION["total".$counter].'</td>
</tr>
';
}
$message = $message.' <tr>
<td align="right" valign="middle"> </td>
<td align="right" valign="middle"> </td>
<td align="right" valign="middle" class="dotted2"><div align="right" class="dgrey" style="font-size:13px">Sub Total: </div></td>
<td valign="middle" class="dotted2" style="font-size:13px"> $'.$_SESSION["grandtotal"].'</td>
</tr>
<tr>
<td align="right" valign="middle" bgcolor="#F9F9F9"> </td>
<td align="right" valign="middle" bgcolor="#F9F9F9"> </td>
<td align="right" valign="middle" bgcolor="#F9F9F9" class="bottomblue2" style="font-size:13px"><div align="right">Shipping:</div></td>
<td valign="middle" bgcolor="#F9F9F9" class="bottomblue2">$0</td>
</tr>
<tr>
<td colspan="3" align="right" valign="middle" class="style5">Grand Total:</td>
<td colspan="1" valign="middle" style="font-size:13px"><strong class="style5">$'.($_SESSION["grandtotal"] + 0).'</strong></td>
</tr>
</table><br>';
//// Mode of payment title
/*$mod1='';
if($_POST['search'] == 'cod')
{
$mod1='Cash On Delivery';
if($_POST['search'] == 'moneypack')
$mod1='MoneyPak';
}
else
{
$mod1='Credit Card / Visa';
}*/
$message = $message.'
<link href="http://xyzsite.com/style.css" rel="stylesheet" type="text/css" /><table width="500" border="0" align="center" cellpadding="4" cellspacing="0" style="border:1px solid #BFBFBF; font-family: Verdana; size:13px" bgcolor="#FFFFFF">
<tr>
<td align="right"></td>
<td style="font-size:13px"><strong>Contact Details</strong> </td>
</tr>
<tr>
<td width="195" align="right" style="font-size:13px">Name: </td>
<td width="293" style="font-size:13px">'.$_POST['txtfname'].' '.$_POST['txtlname'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">Email: </td>
<td style="font-size:13px">'.$_POST['txtemail'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">Phone: </td>
<td style="font-size:13px"> '.$_POST['txtphone'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">Alternate Phone: </td>
<td style="font-size:13px"> '.$_POST['txtphone2'].'
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td align="right" style="font-size:13px"></td>
<td style="font-size:13px"><strong>Shipping Address</strong>
</td>
</tr>
<tr>
<td align="right" style="font-size:13px"> Address: </td>
<td style="font-size:13px">'.$_POST['txtaddress'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">City: </td>
<td style="font-size:13px">'.$_POST['txtcity'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">State: </td>
<td style="font-size:13px">'.$_POST['txtstate'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">Zip: </td>
<td style="font-size:13px">'.$_POST['txtzip'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">Country: </td>
<td style="font-size:13px">'.$_POST['txtcountry'].'</td>
</tr>
';
if(isset($_POST['billing_address']))
{
$message = $message.'
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td align="right"></td>
<td style="font-size:13px"><strong>Billing Address (Blank if same as Shipping Address.)</strong>
</td>
</tr>
<tr>
<td align="right" style="font-size:13px"> Billing Address: </td>
<td style="font-size:13px">'.$_POST['billing_address'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">Billing City: </td>
<td style="font-size:13px">'.$_POST['billing_city'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">Billing State: </td>
<td style="font-size:13px">'.$_POST['billing_state'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">Billing Zip: </td>
<td style="font-size:13px">'.$_POST['billing_zip'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">Billing Country: </td>
<td style="font-size:13px">'.$_POST['billing_country'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">Best Time to Reach You: </td>
<td style="font-size:13px">'.$_POST['txtcall'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">Message: </td>
<td style="font-size:13px">'.$_POST['message'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">IP: </td>
<td style="font-size:13px">'.$_POST['IPAddress'].'</td>
</tr><tr>
<td align="right" style="font-size:13px">IP: </td>
<td style="font-size:13px">'.$_SERVER['REMOTE_ADDR'].'</td>
</tr>
';
}
$message = $message.'</table></html>';
mail($to, $subject, $message, $headers);
//////////// Mail body of Customer Copy
// mail subject
$subject = "Confirmation of Xyz Order Received";
$headers = "From: support@xyzsite.com\r\n";
$headers = "Bcc: campaigns@voiceprocess.net, xyzsite@gmail.com\r\n";
$headers .= "Reply-To: support@xyzsite.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
// Text of body initial
$message='<link href="http://xyzsite.com/style.css" rel="stylesheet" type="text/css" /><table width="750" bgcolor="#FFFFFF" cellpadding="30" style="font-size:13px"><tr><td>Hello '.$_POST['txtfname'].' '.$_POST['txtlname'].',<br><br>
We have received your form submission. Thank you!<br><br>
Below is the data submitted:<br><br>
';
$message=$message.'<html><font family="Verdana" size="2"><table width="698" border="0" cellspacing="0" cellpadding="3" align="center" style="border:1px solid #BFBFBF; font-family: Verdana; size:13px" bgcolor="#FFFFFF">
<tr>
<td height="35" colspan="5">
<div align="center"> <strong style="#004080">Your Cart Details</strong><br />
</div>
</div></td>
</tr>
<tr bgcolor="#B2B2B2">
<td width="390" bgcolor="#006699" class="lglr"><font color="#FFFFFF" style="font-weight:bold; font-size:13px">Product</font></td>
<td width="150" bgcolor="#006699" class="lglr" nowrap="nowrap"><font color="#FFFFFF" style="font-weight:bold; font-size:13px">Payment Method</font></td>
<td width="71" bgcolor="#006699" class="lglr"><font color="#FFFFFF" style="font-weight:bold; font-size:13px">Price</font></td>
<td width="64" bgcolor="#006699" class="lglr" style="font-size:13px"><div align="center"><font color="#FFFFFF" style="font-weight:bold; font-size:13px">Qty</font></div></td>
<td width="65" bgcolor="#006699" class="lglr2"><font color="#FFFFFF" style="font-weight:bold; font-size:13px">Total</font></td>
</tr>';
for ( $counter = 1; $counter <= $_SESSION["cnt"]; $counter += 1)
{
if(($counter%2)==0)
{
$message = $message.' <tr bgcolor="#F9F9F9">';
}
else
{
$message = $message.'<tr>';
}
$message = $message.'
<td class="lglr" style="font-size:13px">'.$_SESSION["title".$counter].'</td>
<td style="font-size:13px" class="lglr">'.$_SESSION["paymentmethod".$counter].'</td>
<td style="font-size:13px" class="lglr"> $'.$_SESSION["price".$counter].'</td>
<td style="font-size:13px" class="lglr3">'.$_SESSION["qty".$counter].'</td>
<td style="font-size:13px" class="lglr2">$'.$_SESSION["total".$counter].'</td>
</tr>
';
}
$message = $message.' <tr style="border-top-color:#CCCCCC; border-top-width:1px">
<td align="right" valign="middle"> </td>
<td align="right" valign="middle"> </td>
<td align="right" valign="middle" class="dotted2" nowrap="nowrap" style="font-size:13px"><div align="right" class="dgrey">Sub Total: </div></td>
<td valign="middle" class="dotted2" style="font-size:13px"> $'.$_SESSION["grandtotal"].'</td>
</tr>
<tr>
<td align="right" valign="middle" bgcolor="#F9F9F9"> </td>
<td align="right" valign="middle" bgcolor="#F9F9F9"> </td>
<td align="right" valign="middle" bgcolor="#F9F9F9" class="bottomblue2" style="font-size:13px"><div align="right">Shipping:</div></td>
<td valign="middle" bgcolor="#F9F9F9" class="bottomblue2" style="font-size:13px">$0</td>
</tr>
<tr>
<td colspan="3" align="right" valign="middle" class="style5" style="font-size:13px">Grand Total:</td>
<td colspan="1" valign="middle" style="font-size:13px"><strong class="style5">$'.($_SESSION["grandtotal"] + 0).'</strong></td>
</tr>
</table><br><br>';
//// Mode of payment title
/*$mod1='';
if($_POST['search'] == 'cod')
{
$mod1='Cash On Delivery';
}
if($_POST['search'] == 'moneypack')
{$mod1='MoneyPak';}
else
{
$mod1='Credit Card / Visa';
}*/
$message = $message.'
<font family="Verdana" size="2">
<table width="500" border="0" align="center" cellpadding="4" cellspacing="0" style="border:1px solid #BFBFBF; font-size:13px; font-family:Verdana" bgcolor="#FFFFFF">
<tr>
<td align="right"></td>
<td><strong style="font-size:13px">Contact Details</strong> </td>
</tr>
<tr>
<td width="195" align="right" style="font-size:13px">Name: </td>
<td width="293" style="font-size:13px">'.$_POST['txtfname'].' '.$_POST['txtlname'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">Email: </td>
<td style="font-size:13px">'.$_POST['txtemail'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">Phone: </td>
<td style="font-size:13px"> '.$_POST['txtphone'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">Alternate Phone: </td>
<td style="font-size:13px"> '.$_POST['txtphone2'].'
</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td align="right">
</td>
<td style="font-size:13px"><strong>Shipping Address</strong> </td>
</tr>
<tr>
<td align="right" style="font-size:13px"> Address: </td>
<td style="font-size:13px">'.$_POST['txtaddress'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">City: </td>
<td style="font-size:13px">'.$_POST['txtcity'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">State: </td>
<td style="font-size:13px">'.$_POST['txtstate'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">Zip: </td>
<td style="font-size:13px">'.$_POST['txtzip'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">Country: </td>
<td style="font-size:13px">'.$_POST['txtcountry'].'</td>
</tr>
';
if(isset($_POST['billing_address']))
{
$message = $message.'
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td align="right"></td>
<td style="font-size:13px"><strong>Billing Address</strong> (Blank if same as Shipping Address.)
</td>
</tr>
<tr>
<td align="right" style="font-size:13px"> Billing Address: </td>
<td style="font-size:13px">'.$_POST['billing_address'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">Billing City: </td>
<td style="font-size:13px">'.$_POST['billing_city'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">Billing State: </td>
<td style="font-size:13px">'.$_POST['billing_state'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">Billing Zip: </td>
<td style="font-size:13px">'.$_POST['billing_zip'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">Billing Country: </td>
<td style="font-size:13px">'.$_POST['billing_country'].'</td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td align="right" style="font-size:13px">Best Time to Reach: </td>
<td>'.$_POST['txtcall'].'</td>
</tr>
<tr>
<td align="right" style="font-size:13px">Message: </td>
<td style="font-size:13px">'.$_POST['message'].'</td>
</tr>
';
}
$message = $message.'</table><br />
<span style="font-size:13px; font-family:Verdana">Thank for your order. A customer care specialist will email you within 1 business day to confirm your order and then it will be shipped upon receipt of payment by confirmation of MoneyPak serial number or Visa card details.<br />
<br />
We Appreciate Your Business,
<br />
<br />
<strong>Support Team</strong><br />
support@xyzsite.com</span><br />
<img src="http://xyzsite.com/images/logosm.png" vspace="5">
</tr></td></table>
</html>';
mail($_POST['txtemail'], $subject, $message, $headers);
session_destroy ();
?>
<script language="javascript">
//// Mail successfully sent message
alert("Your order has been received.\n An email receipt was sent. \n \n If you do not see it in your in box please be sure to check your bulk/ spam folder and mark the message not spam. You should also add support@xyzsite.com to your safe list.\n \n \n \nYou will now be redirected to our reccomended add on product.");
document.location.href="http://www.realk2incense.com/affiliates/idevaffiliate.php?id=202";
</script>
Comment