Jump to content

Show/ Hide Form Fields in Mail Depending Upon User Selection


johnwboyd

Recommended Posts

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:

 

<?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 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"> </td>
                  <td align="right" valign="middle"> </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"> </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>';


$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> </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($_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> </td>
            <td> </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"> </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"> </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"> </td>
                    <td style="font-size:13px">Expiration: '.$_POST['ccexp'].'</td>
                  </tr>
			  <tr> <td style="font-size:13px">MoneyPak # '.$_POST['m-p-n'].'   $'.$_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"> </td>
                    <td style="font-size:13px"> </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>

Link to comment
Share on other sites

Do a var_dump($_POST) and see if the values are getting into your POST.

 

Please give me the entire line of code in context. I got an error in an unsuccessful guesstimate. : )

 

Where to put in here:

 

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']=="")

Link to comment
Share on other sites

Right. Copy the code it dumped to the screen and post it here.

 

array(30) { ["txtfname"]=> string(4) "John" ["txtlname"]=> string(4) "Boyd" ["txtemail"]=> string(21) "XXXX@XXXX.net" ["txtphone"]=> string(10) "XXXXXXXXXX" ["txtphone2"]=> string(0) "" ["txtaddress"]=> string(21) "XXXX XXXX St Suite 2" ["txtcity"]=> string(12) "Laguna Beach" ["txtstate"]=> string(2) "CA" ["txtzip"]=> string(5) "92651" ["txtcountry"]=> string(3) "USA" ["billing"]=> string(7) "billing" ["billing_address"]=> string(0) "" ["billing_city"]=> string(0) "" ["billing_state"]=> string(0) "" ["billing_zip"]=> string(0) "" ["billing_country"]=> string(0) "" [1]=> string(3) "m-p" ["m-p-1"]=> string(18) "324344444444444444" ["cc1"]=> string(0) "" ["cc2"]=> string(0) "" ["cc3"]=> string(0) "" ["cc4"]=> string(0) "" ["ccexp"]=> string(0) "" ["c_v_c"]=> string(0) "" ["m-p-n"]=> string(0) "" ["mpamt"]=> string(0) "" ["txtcall"]=> string(0) "" ["message"]=> string(0) "" ["IPAddress"]=> string(13) "XXX.XX.97.248" ["agree"]=> string(7) "I Agree" }

Link to comment
Share on other sites

Hmm... if this is the issue it will be a BIG problem with the radio buttons as they won't allow unique name and still change from one to the next will they? The IDs of the payment options are unique but the names are the same: 1.  The thing is the payment option data IS working fine as far as straight post vs. show only selected so I'm sure we can get this to work.

 

Thanks so much for your help!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.