.
Virtual Promote Search Engine Forums Free Website Templates  
.

 

 




PHP Credit Card Number Validator Library

Card Number:

This library can be "included" into any PHP application to check the validity of an entered credit card number.

Used properly, it will tell you type of card entered, and if the number entered is a valid one for that card type

Setup and Usage

  • Download the Library and save it as "cccheck.inc.php"
  • In your PHP application, "include" it, like this:
    <?php include_once("/path/to/cccheck.inc.php"; ?>
  • Then, anywhere in your program, you can make calls to the library, as follows:
    Call the "validateCC" function with a credit card number. Returns card type and a 1 on valid card numbers, null on invalid ones.

    $ccnumber = $_POST['credit_card_number'];
    list($type, $valid) = validateCC($number);
    if ( $valid ) {
        // Do something fun with the card
      echo "Number: <b>$ccnumber</b> ... Type: <b>$type</b> ... Valid: <b>$valid</b>";
    }
    else {
      // Return some sort of error
    }
Give it a try here (Don't enter in a real credit card number, though!)

Happy Coding

 

 

Sponsored Links

Search for a Free Domain
The Virtual Promote Toolkit is hosted by the experts at SimpleNet. You should be, too! Whether building a new site or transferring one, there is no other hosting platform comparable to SimpleNet’s; hosting for less than $5/month.
Search for the following tlds: .com, .net, .org, .info, .biz, & .us
Already have a domain or site? Move it to SimpleNet


spacer

 

 

     

© 1995  ·  iWeb, Inc DBA JimWorld Productions