Credit Card Verifier FAQ's

[ Matt's Script Archive ] [ Frequently Asked Questions ] [ Credit Card Verifier ]

  1. Is there a fix which checks the expiry date?


Is there a fix which checks the expiry date?

    The following piece of code was submitted by Dave MacRae, and is said to check the expiry date of your credit card, if you pass the date the user entered to the subroutine like:
      &CheckExpire($FORM{'cardexp'});
    Just put the following subroutine into the script, as well as a call similar to the one above.
      sub CheckExpire {
    
          local ($exp_date) = @_;
          $exp_date =~ s/ //g;
          ($month, $year) = split('/', $exp_date);
          (@thistime) = gmtime(time);
          $thistime[4]++;
          $date = "\"$thistime[5]/$thistime[4]/$thistime[3]:";
    
          if (length($month) > 2 or length($year) > 2) {
              return 0;
          } elsif ($month < 0 or $month > 12) {
              return 0;
          } elsif ($year < $thistime[5]) {
              return 0;
          } elsif ($year == $thistime[5] and $month < $thistime[4]) {
              return 0;
          } else {
              return 1;
          }
      }

[ Matt's Script Archive, Inc. ] [ Advertising ] [ The CGI Resource Index ]

Matt Wright - mattw@scriptarchive.com
© 1995 - 1997 Matt's Script Archive, Inc.