Login   Register  
PHP Classes

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Pierre FAUQUE  >  Checknum Class  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example of use
Class: Checknum Class
Calculate verification numbers using Luhn mod10
Author: By
Last change:
Date: 3 years ago
Size: 1,458 bytes


Class file image Download

<title>Luhn's algorythm</title>

if($_POST["submit"]) {


$_POST["type"] == "verify") {
$test = new checknum($_POST["number"]);
$test->check) { echo $_POST["number"]." : Valid number<br/>"; }
        else             { echo 
$_POST["number"]." : Invalid number<br/>"; }

$_POST["type"] == "add") {
$test = new checknum();
"Number = ";
$_POST["place"] == "before") {
"<span style='color:red;font-weight:bold'>".$test->add_before($_POST["number"])."</span>".$_POST["number"]."<br/>";
$_POST["place"] == "after") {
$_POST["number"]."<span style='color:red;font-weight:bold'>".$test->add_after($_POST["number"])."</span><br/>";



<form name="verify" method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
<input type="text" name="number"><br/>
<input type="hidden" name="type" value="verify">
<input name="submit" type="submit" value="Verify">


<form name="add" method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
<input type="text" name="number"><br/>
<input type="radio" name="place" value="before">Before &nbsp;
<input type="radio" name="place" value="after" checked>After<br/>
<input type="hidden" name="type" value="add">
<input type="submit" name="submit" value="Add digit">