RE: [PHP] Credit card number checker?
| From: | Jeff Pearson | Date: | Mon, 16 Jul 2001 22:39:11 +0000 |
| Subject: | RE: [PHP] Credit card number checker? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-58127@lists.php.net to get a copy of this message | ||
The check you want is called a MOD10 check. Most of the script libraries
have sample code. I found sample codes there. However, when I needed it, I
had to write it in ASP code. Here is the code that I use;
IF AccountNoLength > 16 THEN
ERRORState = "TRUE"
ErrorMssg =
"Account%20Number%20is%20too%20long.Please%20recheck%20and%20reenter."
URL = "CCValidationFailed.asp?ErrorMSSG=" + ErrorMSSG
Response.redirect URL
END IF
IF AccountNoLength < 13 THEN
ERRORState = "TRUE"
ErrorMssg =
"Account%20Number%20is%20too%20short.Please%20recheck%20and%20reenter."
URL = "CCValidationFailed.asp?ErrorMSSG=" + ErrorMSSG
Response.redirect URL
END IF
IF AccountNoLength = 14 THEN
ERRORState = "TRUE"
ErrorMssg = "Account%20Number%20is%20incorrect%20.%20Incorrect%20Length."
URL = "CCValidationFailed.asp?ErrorMSSG=" + ErrorMSSG
Response.redirect URL
END IF
FOR x=1 TO LEN(AccountNo)
ch=MID(AccountNo,LEN(AccountNo)-x+1,1)
IF x mod 2=0 THEN
sum=2*CINT(ch)
qsum=qsum+(sum mod 10)
IF sum>9 THEN
qsum=qsum+1
END IF
ELSE
qsum=qsum+CINT(ch)
END IF
NEXT
IF qsum mod 10<>0 THEN
ERRORState = "TRUE"
ErrorMssg = "Account%20Number%20is%20incorrect%20. Fails%20MOD10%20Check."
URL = "CCValidationFailed.asp?ErrorMSSG=" + ErrorMSSG
Response.redirect URL
END IF
Hope it helps.
Jeff Pearson
> -----Original Message-----
> From: Dr. Evil [mailto:drevil@sidereal.kz]
> Sent: Monday, July 16, 2001 3:12 PM
> To: php-general@lists.php.net
> Subject: [PHP] Credit card number checker?
>
>
>
> I know that credit cards have standard formats: There's a standard
> number of digits, and whether the card is Visa, MC, Amex, etc is
> encoded in the number, and there is some kind of checksum, and I think
> the expiration is also encoded in the number. All of this is obvious
> stuff that anyone designing such a system would do.
>
> I'm wondering if anyone can refer me to a site that describes what
> this format is, so I can write some PHP code that will check to see if
> a credit card number format is correct. I don't even want to try to
> run the card through my merchant account if the format is obviously
> wrong. I assume that banks check the rejection rate on their merchant
> accounts, and too many bogus cards would not look good.
>
> I did a quick search on the web, and there are a vast number of
> "hacker" credit card number generators, but that isn't exactly what
> I'm looking for.
>
> Thanks
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>