PHP Classes

File: hrwsPassport.demo.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Classes of Heiko Rettinger  >  hrwsPassport  >  hrwsPassport.demo.php  >  Download  
File: hrwsPassport.demo.php
Role: Example script
Content type: text/plain
Description: a small example to demonstrate the usage
Class: hrwsPassport
Validates German IdentityCard and Passport numbers
Author: By
Last change: new demo file for the workaround fix of the class file
Date: 11 years ago
Size: 1,667 bytes


Class file image Download
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <title>Identity Card and Passport Check - Demo</title>

<h2>Validation of German Identity Cards or Passport Numbers</h2>

if (isset($_POST['codea'])) {
$card = new hrwsPassport();
$values = $card->pak_check(array($_POST['codea'],$_POST['codeb'],$_POST['codec'],$_POST['coded']));
    if (
$values['valid'] == true) {
"Numbers are valid!<br>".
"Age: ".$values['age']."<br>Birthdate: ";
        if (
$values['birthday'] == -1) {
$monname = array("", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
sprintf("%02d. %s %04d",$values['bday'],$monname[$values['bmonth']],$values['byear']);
        } else echo
strftime("%d. %b %Y", $values['birthday']);
"<br>Valid until: ".strftime("%d. %b %Y", $values['validto'])."<br>\n";
    } else if (
$values['error'] == -1) echo "This Identity Card or Passport has expired!<br>";
    else echo
"Wrong numbers! Please check again.<br>";

"<br><form action=\"\" method=\"post\">".
"Please enter your Identity Card or Passport numbers:<br>\n".
"<input type=\"Text\" name=\"codea\" size=\"10\" maxlength=\"10\" value=\"".$_POST['codea']."\">\n".
"<input type=\"Text\" name=\"codeb\" size=\"7\" maxlength=\"7\" value=\"".$_POST['codeb']."\">\n".
"<input type=\"Text\" name=\"codec\" size=\"7\" maxlength=\"7\" value=\"".$_POST['codec']."\">\n".
"<input type=\"Text\" name=\"coded\" size=\"1\" maxlength=\"1\" value=\"".$_POST['coded']."\">\n".
"<input type=\"Submit\" value=\"validate\"><br>\n".