Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php check credit card expiration

$expires = DateTime::createFromFormat('my', $_POST['expMonth'].$_POST['expYear']);
$now     = new DateTime();

if ($expires < $now) {
    echo 'Expired!';
}
Comment

php credit card validation

<?
/* Luhn algorithm number checker - (c) 2005-2008 shaman - www.planzero.org *
 * This code has been released into the public domain, however please      *
 * give credit to the original author where possible.                      */

function luhn_check($number) {

  // Strip any non-digits (useful for credit card numbers with spaces and hyphens)
  $number=preg_replace('/D/', '', $number);

  // Set the string length and parity
  $number_length=strlen($number);
  $parity=$number_length % 2;

  // Loop through each digit and do the maths
  $total=0;
  for ($i=0; $i<$number_length; $i++) {
    $digit=$number[$i];
    // Multiply alternate digits by two
    if ($i % 2 == $parity) {
      $digit*=2;
      // If the sum is two digits, add them together (in effect)
      if ($digit > 9) {
        $digit-=9;
      }
    }
    // Total up the digits
    $total+=$digit;
  }

  // If the total mod 10 equals 0, the number is valid
  return ($total % 10 == 0) ? TRUE : FALSE;

}
?>
Comment

php validate credit card expiration date

$expires =  date_format( DateTime::createFromFormat('ym', $cc_expiration),"ym");

$now =  date_format(new DateTime(),"ym");

if ($expires < $now) {
    return 'Expired!';
}
Comment

PREVIOUS NEXT
Code Example
Php :: remove all items of an array except the last 5 in php 
Php :: download xampp php 7.3 
Php :: nested with laravel 
Php :: laravel sharing image 
Php :: laravel permission 
Php :: find object in array php 
Php :: link to internal pages in wp php 
Php :: php exit 
Php :: laravel model factory attribute 
Php :: echo php in html 
Php :: php while loop 
Php :: executar comando linux php 
Php :: how to download a file in php 
Php :: php join 
Php :: math functions and predefined constants php 
Php :: laravel collection combine 
Php :: install bcmath php 7.3 ubuntu 
Php :: symfony form submit on refresh 
Php :: rollback to previous php version in linux 
Php :: laravel create resource 
Php :: laravel collection except 
Php :: display php error 
Php :: doctrine getrepository findby 
Php :: laravel eloquent relationship 
Php :: how to start the index from 1 in php? 
Php :: laravel download file change name 
Php :: laravel isset 
Php :: encode zlib php 
Php :: twig to pdf 
Php :: ./yii serve not working in advanced template 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =