PHP Form to ONLY Email Checked Fields...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    PHP Form to ONLY Email Checked Fields...

    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.

    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">&nbsp;</td>
                      <td align="right" valign="middle">&nbsp;</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">&nbsp;</td>
                      <td align="right" valign="middle" bgcolor="#F9F9F9">&nbsp;</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>&nbsp;</td>
                <td>&nbsp;</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>&nbsp;</td>
                <td>&nbsp;</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">&nbsp;</td>
                      <td align="right" valign="middle">&nbsp;</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">&nbsp;</td>
                      <td align="right" valign="middle" bgcolor="#F9F9F9">&nbsp;</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>&nbsp;</td>
                <td>&nbsp;</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>&nbsp;</td>
                <td>&nbsp;</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>&nbsp;</td>
                        <td>&nbsp;</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>
    Last edited by arnage; 28.03.12, 10:59. Reason: Added the code.

    #2
    just use a simple if/else statement eg:
    PHP Code:
    if($_POST['1']=="creditcard")
    {
    $text "get what ever text you need from credit card here";
    }
    else if(
    $_POST['1']=="Split")
    {
    $text "get what ever text you need from Split here";
    else
    {
    $text "get what ever text you need from other option here";

    then just use $text as or part the email

    Comment


      #3
      hmmm

      Thanks but I'm not much of a php coder... just a "noobs" I was hoping you could give me the completed code? I'm lost here... hu hu.

      Comment


        #4
        Alost there just need a lil help!

        I was able to get the Billing Address part to work but the payment method is just not writing to the mail. Can someone please help me fix this?

        The mail code:
        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="xyz@abc.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://xyzco.com/mail-style.css" rel="stylesheet" type="text/css" /><font family="Verdana" size="2"><table width="698" border="0" cellspacing="0" cellpadding="5" 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 bgcolor="#006699" style="padding-left:15px"><font color="#FFFFFF" style="font-weight:bold; font-size:13px">Product</font></td>
        				  <td bgcolor="#006699" style="padding-left:15px" width="150" nowrap="nowrap"><font color="#FFFFFF" style="font-weight:bold; font-size:13px">Payment Method</font></td>
                          <td width="71" bgcolor="#006699" style="padding-left:15px"><font color="#FFFFFF" style="font-weight:bold; font-size:13px">Price</font></td>
                          <td width="64" bgcolor="#006699" 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="lglr" style="padding-left:15px"><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 style="font-size:13px" class="lglr">'.$_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="lglr">'.$_SESSION["qty".$counter].'</td>
        			  <td style="font-size:13px" class="lglr">$'.$_SESSION["total".$counter].'</td>
        			</tr>
        			';
        		}
        		
        	$message = $message.' <tr>
                          <td align="right" valign="middle">&nbsp;</td>
                          <td align="right" valign="middle">&nbsp;</td>
                          <td align="right" valign="middle" class="dotted2" nowrap="nowrap"><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">&nbsp;</td>
                          <td align="right" valign="middle" bgcolor="#F9F9F9">&nbsp;</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>';
        	
        	$message = $message.'
        	<link href="http://xyzco.com/mail-style.css" rel="stylesheet" type="text/css" /><table width="650" 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>&nbsp;</td>
                    <td>&nbsp;</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>&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
        			 <tr>
                    <td width="292">&nbsp;</td>
                    <td width="466">&nbsp;</td>
                  </tr>
        			<tr>
                    <td align="right"></td>
                    <td style="font-size:13px"><strong>Billing Address</strong> <span style="font-size:10px">(Same as above unless noted below.)</span></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; padding-top:2px; vertical-align:top">Message: </td>
                            <td style="font-size:13px">'.$_POST['message'].'</td>
                          </tr>
                          <tr>
                            <td align="right" style="font-size:13px">&nbsp;</td>
                            <td style="font-size:13px">&nbsp;</td>
                          </tr>
                          <tr>
                            <td align="right" style="font-size:13px">&nbsp;</td>
                            <td style="font-size:13px"><strong>Payment Details</strong> (Blank if not selected.)</td>
                          </tr>
                          <tr>
                            <td align="right" style="font-size:13px">MoneyPak:</td>
                            <td style="font-size:13px"># '.$_POST['m-p-1'].'</td>
                          </tr>
                          <tr>
                            <td align="right" style="font-size:13px">Visa Card: </td>
                            <td style="font-size:13px">'.$_POST['cc1'].' '.$_POST['cc2'].' '.$_POST['cc3'].' '.$_POST['cc4'].' </td>
                          </tr>
                          <tr>
                            <td align="right" style="font-size:13px">&nbsp;</td>
                            <td style="font-size:13px">'.$_POST['ccexp'].' '.$_POST['c_v_c'].'</td>
                          </tr>
                          <tr>
                            <td align="right" style="font-size:13px">Split Payment:</td>
                            <td style="font-size:13px">MoneyPak # '.$_POST['m-p-n'].' &nbsp; $'.$_POST['mpamt'].'</td>
                          </tr>
                          <tr>
                            <td colspan="2" style="font-size:13px"><div align="center">---------------------------------------------------------------------------------------</div></td>
                          </tr>
                          <tr>
                            <td align="right" style="font-size:13px; padding-bottom:10px">Agree to the Terms?: '.$_POST['agree'].' </td>
                            <td style="font-size:13px; padding-bottom:10px">IP: '.$_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@xyzco.com\r\n";
        
        	$headers .= "Reply-To: support@xyzco.com\r\n";
        	$headers .= "MIME-Version: 1.0\r\n";
        	$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
        	$headers .= "X-Mailer: PHP/ . phpversion()\r\n";
        	
        	// Text of body initial
        	$message='<html><link href="http://xyzco.com/mail-style.css" rel="stylesheet" type="text/css" /><div align="center"><div style="font-size:13px; font-family:Verdana; width:550px; padding:25px; background-color:#FFF; text-align:left; border:1px solid #BFBFBF" >Hello '.$_POST['txtfname'].' '.$_POST['txtlname'].',<br><br>
         
        We have received your form submission. Thank you!<br><br>
         
        Below is the data submitted:</div></div><br>
        ';
        
        		
        	$message = $message.'<table width="650" border="0" cellspacing="0" cellpadding="5" align="center" style="border:1px solid #BFBFBF; font-family: Verdana; font-size:13px" bgcolor="#FFFFFF"><tr><td>
        <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"><font color="#FFFFFF" style="font-weight:bold; font-size:13px">Product</font></td>
        				  <td bgcolor="#006699" width="150" nowrap="nowrap" class="lglr"><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" style="font-size:13px" class="lglr"><div align="center">
        				  <font color="#FFFFFF" style="font-weight:bold; font-size:13px">Qty</font></div></td>
                          <td width="65" bgcolor="#006699" class="lglr"><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 style="font-size:13px" class="lglr">'.$_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="lglr">'.$_SESSION["qty".$counter].'</td>
        			  <td style="font-size:13px" class="lglr">$'.$_SESSION["total".$counter].'</td>
        			</tr>
        			';
        		}
        		
        	$message = $message.' <tr>
                          <td align="right" valign="middle">&nbsp;</td>
                          <td align="right" valign="middle">&nbsp;</td>
                          <td align="right" valign="middle" class="dotted2" nowrap="nowrap"><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">&nbsp;</td>
                          <td align="right" valign="middle" bgcolor="#F9F9F9">&nbsp;</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>';
        	
        	
        	$message = $message.'
        	
        <font family="Verdana" size="2">
        	<table width="650" border="0" align="center" cellpadding="3" 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>&nbsp;</td>
                    <td>&nbsp;</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($_POST['billing']=="billing")
        {
        $message = $message.='<tr><td><div align="right">Billing Address same as above.</div></td></tr>';}
        else if($_POST['billing']=="")
        {
        $message = $message.'
        
        
                    <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                    <tr>
                    <td align="right"></td>
                    <td style="font-size:13px"><strong>Billing 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></td></tr>';}
        		  
        		  $message = $message.' <tr>
                            <td align="right" style="font-size:13px">&nbsp;</td>
                            <td style="font-size:13px"><strong>Payment Details</strong></td>
                          </tr>';
        
        
             if($_POST['creditcard']=="creditcard")
        {$message = $message.'<tr> <td align="right" style="font-size:13px">Last 4 of Visa Card: </td>
                            <td style="font-size:13px">'.$_POST['cc4'].' </td>
                          </tr>  <tr>
                            <td align="right" style="font-size:13px">&nbsp;</td>
                            <td style="font-size:13px">Expiration: '.$_POST['ccexp'].'</td>
                          </tr>';}
        else if($_POST['creditcard']=="")
        {
        $message = $message."";}
        				 
         if($_POST['split']=="split")
        {$message = $message.'<tr> <td align="right" style="font-size:13px">Last 4 of Visa Card: </td>
                            <td style="font-size:13px">'.$_POST['cc4'].' </td>
                          </tr>  <tr>
                            <td align="right" style="font-size:13px">&nbsp;</td>
                            <td style="font-size:13px">Expiration: '.$_POST['ccexp'].'</td>
                          </tr>
        				  <tr> <td style="font-size:13px">MoneyPak # '.$_POST['m-p-n'].' &nbsp; $'.$_POST['mpamt'].'</td>
                          </tr>
        				  ';}
        else if($_POST['split']=="")
        {
        $message = $message."";}
        				 
         if($_POST['m-p']=="m-p")
        {
        $message = $message.'<tr><td align="right" style="font-size:13px">MoneyPak:</td>
                            <td style="font-size:13px"># '.$_POST['m-p-1'].'</td></tr>';}
        else if($_POST['m-p']=="")
        {
        $message = $message.'';}
        		$message = $message.' 
        		  	  <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" tyle="font-size:13px; padding-top:2px; vertical-align:top">Message: </td>
                            <td style="font-size:13px">'.$_POST['message'].'</td>
                          </tr>
                          <tr>
                            <td align="right" style="font-size:13px">&nbsp;</td>
                            <td style="font-size:13px">&nbsp;</td>
                          </tr>
                    
                          <tr>
                            <td colspan="2" align="right" style="font-size:13px"><div align="center">---------------------------------------------------------------------------------------</div></td>
                          </tr>
                          <tr>
                            <td align="right" style="font-size:13px; padding-bottom:10px">Agree to the Terms?: '.$_POST['agree'].' </td>
                            <td style="font-size:13px; padding-bottom:10px">IP: '.$_SERVER['REMOTE_ADDR'].'</td>
                          </tr></table>		  ';
        	
        	
        	$message = $message.'<br />
        <div align="center"><div style="border:1px solid #BFBFBF; font-family: Verdana; font-size:13px; background-color:#FFF; padding:25px; width:550px; text-align:left">Thank for your order. A customer care specialist will call or 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@xyzco.com</span><br />
        <img src="http://xyzco.com/images/logosm.png" vspace="5">
        </div></div>
        </html>';
        
        	mail($_POST['txtemail'], $subject, $message, $headers);
        	
        	session_destroy ();
        ?>
        
        <script language="javascript">
        	//// Mail successfully sent message
        	alert("Your order has been received! Thank you.\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. Please add support@xyzco.com to your contact/ safe list.\n \n \n \nYou will now be redirected to our reccomended add on product.");
        	document.location.href="xyzlink";
        </script>
        
        
        <style type="text/css">
        <!--
        .style1 {
        	font-family: Verdana, Arial, Helvetica, sans-serif;
        	font-size: 12px;
        }
        -->
        </style>

        Comment


          #5
          thnak you for this share...

          Comment

          Working...
          X