here is the algorithm for checking if a card number is valid
1) must be an integer
2) must be between 13 and 16 digits long
3) if not 16 digits pad left with 0's
4) reverse the string
5) the only hard part :
from left add up all odd spaced digits, from left add up all even spaced digits and multiply them by two and add each digit together- add the results... this can be represented with this multiply mask :
1212121212121212
this means if you have the card number '0000000000000089'
you reverse it to get '9800000000000000'
then apply the multiply mask:
9 x 1 = 9
8 x 2 = 16 so 1 + 6 = 7
9 + 7 = 16
so after the first two digits your running total is 16
6) if the total is evenly devisible by 10 ( $total%10==0 ) then the credit card number is valid
16%10=6 so invalid
7) each type of card Visa, Diners, etc... ontop of this has a range of valid numbes... for instance visa must be 14-16 digits long and start with a 4
mastercard must be 16 digits and start with either 51 or 55
i don't know where a comprehensive list of these things are for each credit card... those are just the ones i know off the top of my head
go ahead and see if you can come up with an algorithm to do what i explained ...