Login   Register  
PHP Classes
elePHPant
Icontem

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 Keith Nunn  >  ISBN check  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: an example script showing usage
Class: ISBN check
Validate ISBN-10, ISBN-13 and convert between them
Author: By
Last change: updated for use with the new php5 version of the class and ISBN-13 changes.
Date: 6 years ago
Size: 1,501 bytes
 

Contents

Class file image Download
<?php
    
echo "<html><body>\n";

    
/*
     *  include class and create object
     */
    
include_once 'isbntest.class.php';
    
$currISBN = new ISBNtest;

    
/*
     *    did we get an ISBN?
     */
    
if ($_REQUEST[isbn]) {
        
$currISBN->set_isbn($_REQUEST[isbn]);
        if (
$currISBN->valid_isbn10() === TRUE) {
            echo 
"<p>The ISBN-10 " $currISBN->get_isbn10() . " is <span style=\"color: green;\">valid</span>.</p>\n";
        } else {
            echo 
"<p>The ISBN-10 " $currISBN->get_isbn10() . " is <span style=\"color: red;\">invalid</span>.</p>\n";
            echo 
"<p>The error reported is:<br /> " $currISBN->get_error() . "</p>\n";
        }
        if (
$currISBN->valid_isbn13() === TRUE) {
            echo 
"<p>The ISBN-13 " $currISBN->get_isbn13() . " is <span style=\"color: green;\">valid</span>.</p>\n";
        } else {
            echo 
"<p>The ISBN-13 " $currISBN->get_isbn13() . " is <span style=\"color: red;\">invalid</span>.</p>\n";
            echo 
"<p>The error reported is:<br /> " $currISBN->get_error() . "</p>\n";
        }
    }

    
/*
     *  input form
     */
    
echo "<FORM ACTION=\"" $PHP_SELF "\" METHOD=\"get\">\n";
    echo 
"<B>isbn</B>\n";
    echo 
"<INPUT TYPE=\"Text\" NAME=\"isbn\" SIZE=\"15\" MAXLENGTH=\"15\" VALUE=\"" $_REQUEST[isbn] . "\">\n";
    echo 
"<INPUT TYPE=\"Submit\" NAME=\"submit\" VALUE=\"Submit\">\n";
    echo 
"</form>\n";

    echo 
"</body></html>\n";

?>