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


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to