<?php
$txtAuthCode = $_POST['txtAuthCode'];
$txtTransactionType = $_POST['txtTransactionType'];
$txtTransactionType_TOKEN = $_POST['txtTransactionType_TOKEN'];
$txtTokenId = $_POST['txtTokenId'];
$txtAuthMessage = $_POST['txtAuthMessage'];
$txtSchemeName = $_POST['txtSchemeName'];

$selMarketingCode = $_POST['selMarketingCode'];
$intIssueStart = $_POST['intIssueStart'];
$chkReceiveSpecialIssues = $_POST['chkReceiveSpecialIssues']; if($chkReceiveSpecialIssues=="") $chkReceiveSpecialIssues="N";
$chkBinders = $_POST['chkBinders']; if($chkBinders=="") $chkBinders="N";
$chkStands = $_POST['chkStands'];
$chkMarketingCode = $_POST['chkMarketingCode']; if($chkMarketingCode=="") $chkMarketingCode="N";

$selTitle = $_POST['selTitle'];
$txtForename = $_POST['txtForename'];
$txtSurname = $_POST['txtSurname'];
$txtAddressLine1 = $_POST['txtAddressLine1'];
$txtAddressLine2 = $_POST['txtAddressLine2'];
$txtTown = $_POST['txtTown'];
$txtCounty = $_POST['txtCounty'];
$txtPostcode1 = $_POST['txtPostcode1'];
$txtPostcode2 = $_POST['txtPostcode2'];
$selCountry = $_POST['selCountry'];
$txtTelephone = $_POST['txtTelephone'];
$txtEmail = $_POST['txtEmail'];
$txtConfirmEmail = $_POST['txtConfirmEmail'];
$selDifferentDeliveryDetails = $_POST['selDifferentDeliveryDetails'];
$selDate_Day = $_POST['selDate_Day'];
$selDate_Month = $_POST['selDate_Month'];
$selDateOfBirth_Year = $_POST['selDateOfBirth_Year'];
$selSex = $_POST['selSex'];
$chkOtherCompanyPromotions = $_POST['chkOtherCompanyPromotions'];  if($chkOtherCompanyPromotions=="") $chkOtherCompanyPromotions="N"; 
$chkThisCompanyPromotions = $_POST['chkThisCompanyPromotions']; if($chkThisCompanyPromotions=="") $chkThisCompanyPromotions="N"; 
$chkEmailMe = $_POST['chkEmailMe']; if($chkEmailMe=="") $chkEmailMe="N";

$txtTelephone_Delivery = $_POST['txtTelephone_Delivery'];
$txtForename_Delivery = $_POST['txtForename_Delivery'];
$txtTown_Delivery = $_POST['txtTown_Delivery'];
$txtCounty_Delivery = $_POST['txtCounty_Delivery'];
$txtPostcode_Delivery1 = $_POST['txtPostcode_Delivery1'];
$txtPostcode_Delivery2 = $_POST['txtPostcode_Delivery2'];
$selTitle_Delivery = $_POST['selTitle_Delivery'];
$txtAddressLine1_Delivery = $_POST['txtAddressLine1_Delivery'];
$txtAddressLine2_Delivery = $_POST['txtAddressLine2_Delivery']; 
$txtSurname_Delivery = $_POST['txtSurname_Delivery'];
$selCountry_Delivery = $_POST['selCountry_Delivery'];

$selPaymentMethod = $_POST['selPaymentMethod'];

$txtCardNumber = $_POST['txtCardNumber'];
$txtCardNumberShort = substr($txtCardNumber,0,4);
$selExpiry_Month = $_POST['selExpiry_Month'];
$selExpiry_Year = $_POST['selExpiry_Year'];
$txtCvsNumber = $_POST['txtCvsNumber'];

$txtMaestroCardNumber = $_POST['txtMaestroCardNumber'];
$txtMaestroCardNumberShort= substr($txtMaestroCardNumber,0,4);
$selMaestroValidFrom_Month = $_POST['selMaestroValidFrom_Month'];
$selMaestroValidFrom_Year = $_POST['selMaestroValidFrom_Year'];
$selMaestroIssueNumber = $_POST['selMaestroIssueNumber'];
$selMaestroExpiry_Month = $_POST['selMaestroExpiry_Month'];
$selMaestroExpiry_Year = $_POST['selMaestroExpiry_Year'];
$txtMaestroCvsNumber = $_POST['txtMaestroCvsNumber'];

$txtMasterCardCardNumber = $_POST['txtMasterCardCardNumber'];
$txtMasterCardCardNumberShort= substr($txtMasterCardCardNumber,0,4);
$selMasterCardExpiry_Month = $_POST['selMasterCardExpiry_Month'];
$selMasterCardExpiry_Year = $_POST['selMasterCardExpiry_Year'];
$txtMasterCardCvsNumber = $_POST['txtMasterCardCvsNumber'];

$txtBankName = $_POST['txtBankName'];if($txtBankName=="Bank Name") $txtBankName="";
$txtAccountNumber = $_POST['txtAccountNumber'];if($txtAccountNumber=="Acc/No") $txtAccountNumber="";
$txtSortCode = $_POST['txtSortCode'];if($txtSortCode=="S/Code") $txtSortCode="";
$txtAccountHolderName = $_POST['txtAccountHolderName'];if($txtAccountHolderName=="Acc Holders Name") $txtAccountHolderName="";



switch ($selPaymentMethod) {
case "Visa/Visa_Delta":
	$strCardExpiry="$selExpiry_Month $selExpiry_Year";
    break;
case "MasterCard":
	$strCardExpiry="$selMasterCardExpiry_Month $selMasterCardExpiry_Year";
	$txtCardNumber="$txtMasterCardCardNumber";
	$txtCvsNumber="$txtMasterCardCvsNumber";
    break;
case "Maestro":
	$strCardExpiry="$selMaestroExpiry_Month $selMaestroExpiry_Year";
	$txtCardNumber="$txtMaestroCardNumber";
	$txtCvsNumber="$txtMaestroCvsNumber";
	$txtSwtichIssueNumber="$txtMaestroCvsNumber";
	$strCardValidFrom="$selMaestroValidFrom_Month $selMaestroValidFrom_Year";
    break;
case "Solo":
	$strCardExpiry="$selMaestroExpiry_Month $selMaestroExpiry_Year";
	$txtCardNumber="$txtMaestroCardNumber";
	$txtCvsNumber="$txtMaestroCvsNumber";
	$txtSwtichIssueNumber="$txtMaestroCvsNumber";
	$strCardValidFrom="$selMaestroValidFrom_Month $selMaestroValidFrom_Year";
    break;
case "Direct_Debit":
	$strCardExpiry="";
    break;
case "Paypal":
	$strCardExpiry="";
    break;	
default:
	$strCardExpiry="Error";
    echo "Error! Payment type not recognised.";
}

//new SQL ODBC connection
$odbc = odbc_connect ('WEBSUBS-SQL', 'websubs2', 'dbf_2010') or die('Could not connect to database - please refresh this page to submit order again.');

$sql = "
INSERT INTO tblSubscriptions (intPublicationId,selMarketingCode,intIssueStart,chkBinders,chkHolders,chkReceiveSpecialIssues,selTitle,txtForename,txtSurname,txtAddressLine1,txtAddressLine2,txtTown,txtCounty,txtPostcode,selCountry,txtTelephone,txtEmail,chkThisCompanyPromotions,chkOtherCompanyPromotions,chkEmailMe,strDateOfBirth,selSex,selTitle_Delivery,txtForename_Delivery,txtSurname_Delivery,txtAddressLine1_Delivery,txtAddressLine2_Delivery,txtTown_Delivery,txtCounty_Delivery,txtPostcode_Delivery,selCountry_Delivery,txtTelephone_Delivery,selPaymentMethod,txtCardNumber,strCardValidFrom,strCardExpiry,txtSwitchCardIssueNumber,txtCvsNumber,txtBankName,txtAccountNumber,txtSortCode,txtAccountHolderName)
values('361','$selMarketingCode','$intIssueStart','$chkBinders','$chkStands','$chkReceiveSpecialIssues','$selTitle','$txtForename','$txtSurname','$txtAddressLine1','$txtAddressLine2','$txtTown','$txtCounty','$txtPostcode1 $txtPostcode2','$selCountry','$txtTelephone','$txtEmail','$chkThisCompanyPromotions','$chkOtherCompanyPromotions','$chkEmailMe','$selDate_Day/$selDate_Month/$selDateOfBirth_Year','$selSex','$selTitle_Delivery','$txtForename_Delivery','$txtSurname_Delivery','$txtAddressLine1_Delivery','$txtAddressLine2_Delivery','$txtTown_Delivery','$txtCounty_Delivery','$txtPostcode_Delivery1 $txtPostcode_Delivery2','$selCountry_Delivery','$txtTelephone_Delivery','$selPaymentMethod','$txtTokenId','$strCardValidFrom','$strCardExpiry','$txtSwitchCardIssueNumber','$txtCvsNumber','$txtBankName','$txtAccountNumber','$txtSortCode','$txtAccountHolderName');
";

//echo "SQL=$sql<BR>";
$query = odbc_exec($odbc, $sql) or die (odbc_errormsg());
$row = odbc_fetch_array($query);

$query = odbc_exec($odbc, "SELECT MAX(intSubscriptionId) AS subID FROM tblSubscriptions;") or die (odbc_errormsg());
$row = odbc_fetch_array($query);
$txtSubID = $row['subID'];
odbc_close($odbc); 



?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Your Subscription: Order Confirmation</title>
<link href="./css/main.css" rel="stylesheet" type="text/css" />
<link href="./css/default.css" rel="stylesheet" type="text/css" />
<link href="./css/bootstrap.css" rel="stylesheet" />
<link href="./css/checkboxs.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="./javascript/generic.js"></script>
<script language="javascript" type="text/javascript" src="./javascript/date.js"></script>
<script language="javascript" type="text/javascript" src="./javascript/validations.js"></script>
<script language="javascript" type="text/javascript" src="./javascript/jquery.icheck.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- This is where the variable is passed from the url -->
<script language="javascript" type="text/javascript">

function BankAccountValidation_Interactive_Validate_v1_00Begin(Key, AccountNumber, SortCode)
   {
      var scriptTag = document.getElementById("PCA2fa66b5844a148ee8994a2cf53992aeb");
      var headTag = document.getElementsByTagName("head").item(0);
      var strUrl = "";

      //Build the url
      strUrl = "https://services.postcodeanywhere.co.uk/BankAccountValidation/Interactive/Validate/v1.00/json.ws?";
      strUrl += "&Key=" + encodeURI(Key);
      strUrl += "&AccountNumber=" + encodeURI(AccountNumber);
      strUrl += "&SortCode=" + encodeURI(SortCode);
      strUrl += "&CallbackFunction=BankAccountValidation_Interactive_Validate_v1_00End";

      //Make the request
      if (scriptTag) 
         {
            try
              {
                  headTag.removeChild(scriptTag);
              }
            catch (e)
              {
                  //Ignore
              }
         }
      scriptTag = document.createElement("script");
      scriptTag.src = strUrl
      scriptTag.type = "text/javascript";
      scriptTag.id = "PCA2fa66b5844a148ee8994a2cf53992aeb";
      headTag.appendChild(scriptTag);
   }

function BankAccountValidation_Interactive_Validate_v1_00End(response)
   {
      //Test for an error
      if (response.length==1 && typeof(response[0].Error) != 'undefined')
         {
            //Show the error message
            alert(response[0].Description);
         }
      else
         {
            //Check if there were any items found
            if (response.length==0)
               {
                  alert("Sorry, no matching items found");
               }
            else
               {
                  //document.getElementById('status').innerHTML = response[0].StatusInformation;
				  statusCheck = response[0].StatusInformation;
				  if (statusCheck == "OK" || statusCheck == "CautiousOK")
					{statusCheck = "This account supports Direct Debits"}
				  if (statusCheck == "InvalidAccountNumber")
					{
					statusCheck = "This account does not support Direct Debits - please use a different account";
					alert(statusCheck);
					}
				  if (statusCheck == "UnknownSortCode")
					{
					statusCheck = "This SORT CODE isn't recognised - please check and amend";
					alert(statusCheck);
					}
			
				  document.getElementById('txtBankName').value = response[0].Bank;
				  
//More information on this API, as well as the entire set of fields returned can be found at:
//http://www.postcodeanywhere.co.uk/support/webservices/BankAccountValidation/Interactive/Validate/v1/default.aspx

               }
         }
   }


</script>
</head>

<!-- this bit of code creates todays date in the following format mmm-yyyy -->
<script type="text/javascript">
function showMe (it, box) {
  var vis = (box.checked) ? "block" : "none";
  document.getElementById(it).style.display = vis;
}
function hideVisa()
{
	document.getElementById('frmSubscription').action = "https://www.dbfactory2.co.uk/gateway/processing_page_token.asp?FAMILY_CODE=RA";
document.getElementById('divPaypal').style.display = 'none';	
document.getElementById('divVisa').style.display = "block";
document.getElementById('divMastercard').style.display = "none";
//document.getElementById('divMaestro').style.display = "none";
document.getElementById('divDirectdebit').style.display = "none";
document.getElementById('divOptions').style.display = "block";

	  //blank dd and mastercard fields - KC 11032011
	  document.getElementById('txtMastercardName').value = '';
	  document.getElementById('txtMasterCardCardNumber').value = '';
	  document.getElementById('txtMasterCardCvsNumber').value = '';

      document.getElementById('txtAccountHolderName').value = '';
      document.getElementById('txtAccountNumber').value = '';
      document.getElementById('txtSortCode').value = '';
      document.getElementById('txtBankName').value = '';
	  ////////////////////////////////
}
function hideMC()
{
	document.getElementById('frmSubscription').action = "https://www.dbfactory2.co.uk/gateway/processing_page_token.asp?FAMILY_CODE=RA";
document.getElementById('divPaypal').style.display = 'none';	
document.getElementById('divMastercard').style.display = 'block';
document.getElementById('divVisa').style.display = 'none';
//document.getElementById('divMaestro').style.display = 'none';
document.getElementById('divDirectdebit').style.display = 'none';
document.getElementById('divOptions').style.display = "block";

	  //blank dd and visa fields - KC 11032011
	  document.getElementById('txtCardName').value = '';
	  document.getElementById('txtCardNumber').value = '';
	  document.getElementById('txtCvsNumber').value = '';	
	  
	  document.getElementById('txtAccountHolderName').value = '';
	  document.getElementById('txtAccountNumber').value = '';
	  document.getElementById('txtSortCode').value = '';
	  document.getElementById('txtBankName').value = '';
	  ///////////////////////////
}
function hideMaestro()
{
   document.getElementById('frmSubscription').action = "https://www.dbfactory2.co.uk/gateway/processing_page_token.asp?FAMILY_CODE=RA";
document.getElementById('divPaypal').style.display = 'none';	
//document.getElementById('divMaestro').style.display = 'block';
document.getElementById('divVisa').style.display = 'none';
document.getElementById('divMastercard').style.display = 'none';
document.getElementById('divDirectdebit').style.display = 'none';
document.getElementById('divOptions').style.display = "block";
}
function hideDirectdebit()
{
document.getElementById('frmSubscription').action = "page3.php";
document.getElementById('divPaypal').style.display = 'none';
document.getElementById('divDirectdebit').style.display = 'block';
document.getElementById('divVisa').style.display = 'none';
//document.getElementById('divMaestro').style.display = 'none';
document.getElementById('divMastercard').style.display = 'none';
document.getElementById('divOptions').style.display = "block";

	  //blank visa and mastercard fields - KC 11032011
	  document.getElementById('txtCardName').value = '';
	  document.getElementById('txtCardNumber').value = '';
	  document.getElementById('txtCvsNumber').value = '';

	  document.getElementById('txtMastercardName').value = '';
	  document.getElementById('txtMasterCardCardNumber').value = '';
	  document.getElementById('txtMasterCardCvsNumber').value = '';	  
	  //////////////////////////////////
}

function hidePaypal()
{
	document.getElementById('frmSubscription').action = "page3.php";
document.getElementById('divPaypal').style.display = 'block';
document.getElementById('divDirectdebit').style.display = 'none';
document.getElementById('divVisa').style.display = 'none';
//document.getElementById('divMaestro').style.display = 'none';
document.getElementById('divMastercard').style.display = 'none';
//document.getElementById('divOptions').style.display = "none";
}

function showInvoice(){

var selValue
selValue= document.getElementById('selDifferentDeliveryDetails').value;
if (document.getElementById('selDifferentDeliveryDetails').value !== "No")
	{
	hidedev();
	document.getElementById('txtForename_Delivery').readOnly=""; 	
	document.getElementById("txtForename_Delivery").focus();
	document.getElementById("txtSurname_Delivery").readOnly=""; 	
	document.getElementById("txtAddressLine1_Delivery").readOnly=""; 	
	document.getElementById("txtAddressLine2_Delivery").readOnly=""; 	
	document.getElementById("txtTown_Delivery").readOnly=""; 	
	document.getElementById("txtCounty_Delivery").readOnly=""; 	
	document.getElementById("txtPostcode_Delivery1").readOnly=""; 	
	document.getElementById("txtPostcode_Delivery2").readOnly=""; 	
	document.getElementById("selCountry_Delivery").readOnly=""; 	
	document.getElementById("txtTelephone_Delivery").readOnly=""; 	
	document.getElementById("txtEmail_Delivery").readOnly=""; 	
	document.getElementById("txtConfirmEmail_Delivery").readOnly=""; 			
	}else{
	unhiddev();
	}
	
}

 <!-- 
var pageDateForExpiryDate;
// Array of month Names
var monthNames = new Array(
"Jan","Feb","Mar","Apr","May","Jun","Jul",
"Aug","Sep","Oct","Nov","Dec");

var now = new Date();
pageDateForExpiryDate = (monthNames[now.getMonth()] + "-" + now.getFullYear());

// -->
	
  
		function optionChoose() {
				if(document.form1.BILLRADIO[0].checked) {
					if((document.form1.WESBILLTYPE.options[document.form1.WESBILLTYPE.selectedIndex].value == "") ||
					(document.form1.WESBILLTYPE.options[document.form1.WESBILLTYPE.selectedIndex].value == "Z")){
						alert("Please select a credit card type.");
					    return false;
						}
					 else {return true}		
				  }
				 else if(document.form1.BILLRADIO[1].checked) {
				 		document.form1.WESBILLTYPE.selectedIndex=0
						document.form1.MSCCRDNR.value = ""
						document.form1.WESEXPMM.value = ""
						document.form1.WESEXPYY.value = ""
	    				return true;
				}
				 else {
					alert("Please check the pay by credit card or bill me option.");
					return false;
				}
			}

			function checkEmail(){
			 
				var emailvalue = document.form1.MSREMAIL.value;
				var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; 
				if(emailvalue != ""){	
						if (emailPattern.test(emailvalue)) {
							return true;
						} else  {
							alert("Please enter a valid e-mail address.");
							document.form1.MSREMAIL.focus;
							return false;
						}
					} else  {
						return true;
				}	
						
			}
			
			function submitForm(){
			checkBox();
			if(optionChoose() && checkEmail() && compareEmails()) {
			    document.form1.submit();
			  }			
			}


// No Right Click Script //
function MM_openBrWindow(theURL,winName,features) { //v2.0 
window.open(theURL,winName,features);}
<!--

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

<!--
//
function openWin(pageName)  {
var features = 'status=no,scrollbars=yes,width=500,height=385';
window.open(pageName,"win1", features );
}
function inb_openWin(Url,Name,Width,Height,Scrollbars)  {
var features = 'status=no,scrollbars=' + Scrollbars + ',width=' + Width +
',height=' + Height;
window.open(Url, Name, features );
}

//-->
</script>
<script type="text/javascript">
function hidedev(){
document.getElementById('deliveryaddress').style.display ='none'; 
document.getElementById('otherpayment').style.display ='block'; 
document.getElementById('devtext').innerHTML  ='Delivery Details <a href=# onclick=unhiddev()>(unhide)</a>';
document.getElementById('billad').innerHTML  ='Billing Address';
}
function unhiddev(){

	if (document.getElementById('selDifferentDeliveryDetails').value == "Yes")
		{
		document.getElementById('deliveryDiv').style.display ='block'; 
		}
	else
		{
		document.getElementById('deliveryDiv').style.display ='none'; 
		}
}

function paypalOption(){
check = document.getElementById('intIssueStart').value;

if (check > 5)
	{
	document.getElementById('paypalOption').style.display = "none";
	}
else
	{
	document.getElementById('paypalOption').style.display = "block";
	}
	
}


function countryCheck() {
check = document.getElementById('selCountry').value;
if (check == "Eire")
	{
	document.getElementById('ddHide').innerHTML = "Unfortunately we do not accept Direct Debit from Eire";
	}
else
	{
	document.getElementById('ddHide').innerHTML = "<img src='images/directDebitLogo2.gif' alt='Direct Debit' width='45' height='45' align='absmiddle' style='display:inline' /><br /><input type='radio' name='selPaymentMethod_1' id='selPaymentMethod_1' value='Direct_Debit' onclick='document.getElementById('selPaymentMethod').value='Direct_Debit';javascript:hideDirectdebit();' />";
	}
	
}
</script>

</head>
<body>
<script type="text/javascript" src="javascript/wz_tooltip.js"></script> <!-- this loads the tooltip plugin -->
<div id="wrapper">
  		<div id="banner" align="center">
		  <table width="100%" border="0">
		    <tr>
        <td align="center"><img src="images/hachette.jpg" alt="Hachette" /></td>
	        </tr>
	      </table>
    </div>
		
    
    <!-- this is the FAQ bit -->
     <div id="content">
<div id="bar">
        			<h2>Payment Update Confirmation</h2>           
                    </div>
<!-- START bmbPageContent -->
<div id="bmbPageOutterContent">
<div id="bmbConfirmationPageContent">
<h2>REFERENCE: <?php echo("$selMarketingCode");?></h2>
<p>Dear <?php echo("$selTitle $txtForename $txtSurname");?>,</p>
<p>If you have any queries please email customer_service_aus@hachette-service.com.</p>
<p>Kind regards<br />
  <br /> 
  Hachette
</p><h2>PAYEE DETAILS</h2><table style="border: 0;"><tr><td style="text-align: right;">Title:</td><td><?php echo("$selTitle");?></td></tr><tr><td style="text-align: right;">First Name:</td><td><?php echo("$txtForename");?></td></tr><tr><td style="text-align: right;">Surname:</td><td><?php echo("$txtSurname");?></td></tr><tr><td style="text-align: right;">Address Line 1:</td><td><?php echo("$txtAddressLine1");?></td></tr><tr><td style="text-align: right;">Address Line 2:</td><td><?php echo("$txtAddressLine2");?></td></tr><tr><td style="text-align: right;">Town:</td><td><?php echo("$txtTown");?></td></tr><tr><td style="text-align: right;">County:</td><td><?php echo("$txtCounty");?></td></tr><tr><td style="text-align: right;">Postcode:</td><td><?php echo("$txtPostcode1 $txtPostcode2");?></td></tr><tr><td style="text-align: right;">Country:</td><td><?php echo("$selCountry");?></td></tr><tr><td style="text-align: right;">Email:</td><td><?php echo("$txtEmail");?></td></tr></table>

<?php 
switch ($selPaymentMethod) {
case "Visa/Visa_Delta":
?>
	<h2>PAYMENT DETAILS</h2><table style="border: 0;"><tr><td style="text-align: right;">Payment Type:</td><td><?php echo($selPaymentMethod);?></td></tr><tr><td style="text-align: right;">Card Number:</td><td><?php echo(substr($txtCardNumber,0,4));?> XXXX XXXX XXXX</td></tr><tr><td style="text-align: right;">Expiry:</td><td><?php echo("$selExpiry_Month $selExpiry_Year");?></td></tr></table>
<?php
    break;
case "MasterCard":
?>
	<h2>PAYMENT DETAILS</h2><table style="border: 0;"><tr><td style="text-align: right;">Payment Type:</td><td><?php echo($selPaymentMethod);?></td></tr><tr><td style="text-align: right;">Card Number:</td><td><?php echo(substr($txtMasterCardCardNumber,0,4));?> XXXX XXXX XXXX</td></tr><tr><td style="text-align: right;">Expiry:</td><td><?php echo("$selMasterCardExpiry_Month $selMasterCardExpiry_Year");?></td></tr></table>
<?php
    break;
case "Maestro":
?>
	<h2>PAYMENT DETAILS</h2><table style="border: 0;"><tr><td style="text-align: right;">Payment Type:</td><td><?php echo($selPaymentMethod);?></td></tr><tr><td style="text-align: right;">Card Number:</td><td><?php echo(substr($txtMaestroCardNumber,0,4));?> XXXX XXXX XXXX</td></tr><tr><td style="text-align: right;">Expiry:</td><td><?php echo("$selMaestroExpiry_Month $selMaestroExpiry_Year");?></td></tr></table>
<?php
    break;
case "Solo":
?>
	<h2>PAYMENT DETAILS</h2><table style="border: 0;"><tr><td style="text-align: right;">Payment Type:</td><td><?php echo($selPaymentMethod);?></td></tr><tr><td style="text-align: right;">Card Number:</td><td><?php echo(substr($txtMaestroCardNumber,0,4));?> XXXX XXXX XXXX</td></tr><tr><td style="text-align: right;">Expiry:</td><td><?php echo("$selMaestroExpiry_Month $selMaestroExpiry_Year");?></td></tr></table>
<?php
    break;
case "Direct_Debit":
?>
	<h2>PAYMENT DETAILS</h2>

<!-- this is the old confirmation	
<table style="border: 0;"><tr><td style="text-align: right;">Payment Type:</td><td><?php echo($selPaymentMethod);?></td></tr><tr><td style="text-align: right;">Bank Name:</td><td><?php echo("$txtBankName");?></td></tr><tr><td style="text-align: right;">Account Number:</td><td><?php echo(substr($txtAccountNumber,0,4));?>...</td></tr><tr><td style="text-align: right;">Sort Code:</td><td><?php echo("$txtSortCode");?></td></tr><tr><td style="text-align: right;">Account Holder's Name:</td><td><?php echo("$txtAccountHolderName");?></td></tr></table>
 -->

<!-- this is the new DDI confirmation -->
<div>
Please note - you will receive confirmation of the setup of your direct debit instruction within 3 working days.
</div>
<div class="ddImage">

<table width="412" height="396" border="0" background="./images/RBA_DDI.gif">
  <tr>
    <th scope="col" height="27">&nbsp;</th>
  </tr>
  <tr>
    <td height="13" width="7">&nbsp;</td> <!-- this is the indent -->
    <td height="13" style="font-size:9px; font-family:Arial, Helvetica, sans-serif" align="left" >Precious Rocks and Minerals collection</td>
    <td height="13" width="14">&nbsp;</td>
  </tr>
  <tr>
    <td width="7">&nbsp;</td> <!-- this is the indent -->
    <td></td>
	<td height="50" align="center" valign="bottom">
	<font size="1" style="font-family:Arial, Helvetica, sans-serif"><strong>Bank or Building Society:</strong></font>
	</td>
  </tr>
  <tr>
    <td height ="87" width="7">&nbsp;</td> <!-- this is the indent -->
    <td align="left" valign="bottom"><font size="1" style="font-family:Arial, Helvetica, sans-serif"><strong>Name of Account Holder:</strong></font></td>
    <td align="center" valign="top">
	<?php echo("$txtBankName");?>
	</td>
  </tr>
  <tr>
    <td height="20" width="7">&nbsp;</td> <!-- this is the indent -->
    <td height="20">
	<?php echo("$txtAccountHolderName");?>
	</td>
    <td height="20">&nbsp;</td>
  </tr>
  <tr>
    <td width="7">&nbsp;</td> <!-- this is the indent -->
    <td>
	<font size="1" style="font-family:Arial, Helvetica, sans-serif"><strong>Branch Sort Code:</strong></font>
	<br />
	<?php echo("$txtSortCode");?>
	</td>
    <td width="220" align="center">
	<font size="1" style="font-family:Arial, Helvetica, sans-serif"><strong>Bank or Building Society Account Number:</strong></font>
	<br/>
	<?php echo(substr($txtAccountNumber,0,4));?>
	</td>
  </tr>
  <tr>
    <td height="117" width="7">&nbsp;</td> <!-- this is the indent -->
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>


</div>

	
	
<?php
    break;
default:
    echo "Error! Payment type not recognised.";
}

//Prepare and send email


$to      = "cfd@konecta-group.com";
$subject = 'Customer Payment Update';
$message = "

CUSTOMER DETAILS

Magazine Title: $chkStands
your order reference number: $selMarketingCode

---------------------------
 
PAYEE DETAILS

Title: $selTitle
First Name: $txtForename
Surname: $txtSurname
Address Line 1: $txtAddressLine1
Address Line 2: $txtAddressLine2
Town: $txtTown
County: $txtCounty
Postcode: $txtPostcode1 $txtPostcode2
Country: $selCountry

Email: $txtEmail
--------------------------- 
";

if ($selPaymentMethod=="Visa/Visa_Delta")
{
$message.="
PAYMENT DETAILS

Payment Type: $selPaymentMethod
Token ID: $txtTokenId
Expiry: $selExpiry_Month $selExpiry_Year
---------------------------
";
}
else if ($selPaymentMethod=="MasterCard")
{
$message.="
PAYMENT DETAILS

Payment Type: $selPaymentMethod
Token ID: $txtTokenId
Expiry: $selMasterCardExpiry_Month $selMasterCardExpiry_Year
---------------------------
";
}
else
{
$message.="
PAYMENT DETAILS

Payment Type: $selPaymentMethod
Bank Name: $txtBankName
Account Number: $txtAccountNumber
Sort Code:$txtSortCode
Account Holders Name: $txtAccountHolderName
---------------------------
";
}

$message.="This offer is only available in the UK. All orders are subject to acceptance. Gifts may vary from examples shown and are subject to availability. You may cancel at any time.";


$headers = 'From: donotreply@dbfactory2.co.uk' . "\r\n" .
    'Reply-To: donotreply@dbfactory2.co.uk' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>


</div>

</div>
</div>
<!-- END bmbPageContent -->
<div>
	<div id="footer">
	<a> This site is provided by </a><a href="http://www.dbfactory.co.uk">Data Base Factory Ltd</a><a> on behalf of </a>Hachette.
	<br />

	<a> This site is protected by Thawte using 256bit encryption for your security.</a>
	<br />
	<br />
	<!-- this is the Thawte site seal -->
	<table width="10" border="0" cellspacing="0" align="center">
 <tr>
  <td>
   <script src="https://siteseal.thawte.com/cgi/server/thawte_seal_generator.exe"></script>
  </td>
 </tr>
 <tr>
  <td height="0" align="center">
   <a style="color:#AD0034" target="_new"
   href="http://www.thawte.com/digital-certificates/">
   <span style="font-family:arial; font-size:8px; color:#AD0034">
   ABOUT SSL CERTIFICATES</span>
   </a>
  </td>
 </tr>
</table>
<!-- this is the end of the Thawte site seal code -->
	<br />
	<table align="center" width="100" border="0">
  <tr>
    <th scope="col"><img src="./images/visaLogo.gif" /></th>
    <th scope="col"><img src="./images/mastercardLogo.gif" /></th>
    <th scope="col"><img src="./images/DeltaLogo.gif" /></th>
    <th scope="col"><img src="./images/electronLogo.gif" /></th>	
    <th scope="col"><img src="./images/directdebitLogo2.gif"/></th>
	<th scope="col">&nbsp;</th>
	<th scope="col">&nbsp;</th>
	<th scope="col">&nbsp;</th>
	<th scope="col">&nbsp;</th>
	<th scope="col">&nbsp;</th>

  </tr>
</table>
<!-- this is the end of the Thawte site seal code -->
	<br />
	<a> &copy; 2018</a>
</div>
</div>
</div>

</body>
</html>
