Step 1: First create creditcard.php file and use the below code.
<?php include("creditcard_valid.php"); if(isset($_POST['submit'])) { $credit_card_cc_owner = $_POST['credit_card_cc_owner']; $cardnumber = $_POST['credit_card_cc_number']; $cardname = $_POST['credit_card_type']; $cardcvv = $_POST['credit_card_cvv']; $card_cc_expires_month = $_POST['credit_card_cc_expires_month']; $card_cc_expires_year = $_POST['credit_card_cc_expires_year']; $error=false; if (strlen($credit_card_cc_owner) < 3) { $error = true; $Errormessage.="The Owner\'s name of the credit card must be at least 3 characters. "; } if (strlen($cardnumber) < 13) { $error = true; $Errormessage.="The Credit Card number must be at least 13 characters. "; } if (strlen($credit_card_cvv) < 3) { $error = true; $Errormessage.="The Credit Card cvv number must be at least 3 characters. "; } if(!tep_validateCC($cardnumber,$cardname)) { $error = true; $Errormessage.="Please make sure that you entered a valid Credit Card Number. "; } if(!tep_CheckCVV($cardnumber,$cardcvv)) { $error = true; $Errormessage.="Please make sure that you entered valid CVV Number. "; } if(!tep_CheckCreditCardExpirationDate($card_cc_expires_month,$card_cc_expires_year)) { $error = true; $Errormessage.="Please Select Valid Date"; } if($error==false) $Successmessage="Your Credit card is valid"; } ?> Credit Card Validation Java+PHP Example <script type="text/javascript" language="javascript" src="creditcard.js"></script></pre> <form action="" method="post" name="creditcard" onsubmit="return check_form(creditcard);"> <table width="30%" border="0" cellspacing="0" cellpadding="2" align="center"> <tbody> <tr> <td colspan="2"><?php if($error==1) { echo '<span style="color: #ff0000;">'.$Errormessage.'</span>'; } else { echo '<span style="color: #76c776;">'.$Successmessage.'</span>';} ?></td> </tr> <tr> <td class="main" width="180">Credit Card Owner:</td> <td class="main"><input type="text" name="credit_card_cc_owner" /></td> </tr> <tr> <td class="main" width="180">Credit Card Type:</td> <td class="main"><select name="credit_card_type"><option value="Amex">Amex</option><option value="Mastercard">Mastercard</option><option value="Visa">Visa</option></select></td> </tr> <tr> <td class="main" width="180">Credit Card Number:</td> <td class="main"><input type="text" name="credit_card_cc_number" /></td> </tr> <tr> <td class="main" width="180">Credit Card Expiry Date:</td> <td class="main"><select name="credit_card_cc_expires_month"><option value="01">January</option><option value="02">February</option><option value="03">March</option><option value="04">April</option><option value="05">May</option><option value="06">June</option><option value="07">July</option><option value="08">August</option><option value="09">September</option><option value="10">October</option><option value="11">November</option><option value="12">December</option></select> <select name="credit_card_cc_expires_year"><option value="2011">2011</option><option value="2012">2012</option><option value="2013">2013</option><option value="2014">2014</option><option value="2015">2015</option><option value="2016">2016</option><option value="2017">2017</option><option value="2018">2018</option><option value="2019">2019</option><option value="2020">2020</option></select></td> </tr> <tr> <td class="main" width="180">CVV number</td> <td class="main"><input type="text" name="credit_card_cvv" size="4," maxlength="4" /></td> </tr> <tr> <td class="main" width="180"></td> <td class="main"><input type="submit" name="submit" value="Submit" /></td> </tr> </tbody> </table> </form> <pre>
Step 2: You can download creditcard_valid.php file: creditcard_valid.php
Step 3: You can download creditcard.js file : creditcard.js
Step 4: Now run your creditcard.php file and you can enjoy the javascript and PHP Caredit card validation on your site.
Speak Your Mind