Re: How check credit card or magnetic card number.
| From: | Jas | Date: | Mon, 02 Feb 2004 17:47:29 +0000 |
| Subject: | Re: How check credit card or magnetic card number. | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-176592@lists.php.net to get a copy of this message | ||
Pedro wrote:
Hi, how i can check credit card or magnetic card number for a site of electronic commerce that i have to design. Sorry for my english. Pedro. <?php//Check credit card & date on HTML form if(empty($_POST['cc']) || (empty($_POST['ccd'])) { echo "Credit card and date fields not submitted."; } else { //Check formats for various card types & date if(eregi("^4[0-9]{16}$",$_POST['cc'])) || eregi("^[0-9]{2}/+[0-9]{2}$",$_POST['ccd'])) {
echo "You card is a Visa Card";if(eregi("^5[0-9]{16}$",$_POST['cc'])) || eregi("^[0-9{2}/+[0-9]{2})) {
echo "Your card is a Mastercard"; }?> You get the idea, you may to need to Google around for the various credit card types and how the need them to be formatted, and my regular expressions may need to be adjusted as I have not tested them out. But that is just an example of how you would accomplish your goal. HTH Jas