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