In this article i have explain How to validate the credit card using php this funtion This function will validate a credit card is valid or not.

Bellow is the list of rules for top six most popular credit cards :

  • mastercard: Must have a prefix of 51 to 55, and must be 16 digits in length.
  • Visa: Must have a prefix of 4, and must be either 13 or 16 digits in length.
  • American Express: Must have a prefix of 34 or 37, and must be 15 digits in length.
  • Diners Club: Must have a prefix of 300 to 305, 36, or 38, and must be 14 digits in length.
  • Diners Club: Must have a prefix of 300 to 305, 36, or 38, and must be 14 digits in length.
  • Discover: Must have a prefix of 6011, and must be 16 digits in length.
  • JCB: Must have a prefix of 3, 1800, or 2131, and must be either 15 or 16 digits in length.

cccard-validation_php

PHP Function

Download      Demo

You can use this libraryfunction to validate the credit card. This is free for Demo and code download. Please see the demo first and if you like it then download it.

I hope you like this simple and easy PHP function if yes then please feel free to comment below.