Anikin's code will check the luhn-10 checksum of a credit-card number presented. Use it.
I recommend you also perform other other checks, too, based on the type of card. For example, it is possible to input a supposed Visa number that passes luhn-10, but does not begin with a "4", as all Visa card numbers must.
Here's the guts of a switch statement I have used in my code before:
[tt]
$cc_good = FALSE;
switch ($cc_brand)
{
case "MasterCard" :
$cc_good = preg_match ("/^5[1-5]\d{14}$/", $cc_num);
break;
case "Visa" :
$cc_good = preg_match ("/^4\d{15}$|^4\d{12}$/", $cc_num);
break;
case "American Express" :
$cc_good = preg_match ("/^3[47]\d{13}$/", $cc_num);
break;
case "Discover" :
$cc_good = preg_match ("/^6011\d{12}$/", $cc_num);
break;
case "Diner's Club" :
$cc_good = preg_match ("/^30[0-5]\d{11}$|^3[68]\d{12}$/", $cc_num);
break;
case "Japan Credit Bank" :
$cc_good = preg_match ("/^3\d{15}$|^2131\d{11}$|1800\d{15}$/", $cc_num);
break;
default :
break;
}[/tt] ______________________________________________________________________
My God! It's full of stars!
______________________________________________________________________