'; ?>
Universal Credit Card form
// ERROR CODES
// CC001 Name contains illegal characters
// CC002 Name has invalid length
// CC011 Credit card checksum invalid
// CC012 Credit card invalid length
// CC013 Credit card not digits
// CC021 Expirydate expired
// CC022 Expirydate invalid
// CC033 Check code invalid length
// CC033 Check code not digits
$cardnumber = $URL = $_GET['cardnumber'];
if ($cardnumber!=0){
/* if the month of exp is passed,this year, card is expired */
/* Remember that the card will never be a year in the past as the year list */
/* has been created starting from $thisyear (see next)*/
// if($month<$thismonth and $year==$thisyear) exit("Card has expired!");
$cclen=strlen($cardnumber);
/* Check card number lenght: must be 15 or 13 or 16 */
if ($cclen!=13 and $cclen!=15 and $cclen!=16) $ERROR = "Please check the credit card number length";
mod10($cardnumber);
}
function mod10($cardnumber) {
/* Check if the card has a pair or odd number of digits */
/* the % give the rest of a division, like: 5 divided 2 -> give 1 */
if ($cclen%2==0) {
$p=0; } /* PAIR */
else {$p=2;} /* ODD */
/* Get each number of the card and put it in an array */
for($a=0;$a!=$cclen;$a++){
$X[$a]=substr($cardnumber,$a,1);
}
/* Algorithm Mod10 */
for ($nume=($p/2);$nume!=$cclen-$p;$nume=$nume+2){
$X[$nume]=$X[$nume]*2;
if ($X[$nume]>=10) {
$X1=substr($X[$nume],0,1);
$X2=substr($X[$nume],1,1);
$X[$nume]=substr($X[$nume],0,1)+substr($X[$nume],1,1);
}
}
/* Sums each value of the modificated array */
/* Check the result of the algorithm */
for ($i=0;$i!=$cclen;$i++){
$val=$val+$X[$i];
}
/* Please note: if the second number of the result of algorithm is not 0 */
/* then the card is NOT valid */
if ($val==0)
{$ERROR = "Please check the credit card number" ;}
else {
if (substr($val,1,1)!=0){ $valida="not";}
echo ("The card: $cardnumber seems to be: $valida valid");
exit();
/* This condition in the case $card contains characters */
exit("Maybe the Card Number inserted contains characters ? Only numbers
please!");
}
}
if ($ERROR) {
echo "" . $ERROR . "
";
}
?>