PHP Classes

File: example.php

Recommend this page to a friend!
  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: 13 years ago
Size: 1,458 bytes
 

Contents

Class file image Download
<html>

<head>
<title>Luhn's algorythm</title>
</head>

<body>
<?php
if($_POST["submit"]) {

    require(
"checknum.php");

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

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

}
?>

<hr>NO SUBMIT FORM VERIFICATION. JUST A WORK TEST<hr>

<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>

<hr>

<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">
</form>

</body>
</html>