<?
  
include("functions.php");

  if (isset(
$_GET['code'])) {

    
$code $_GET['code'];
    
$type strtoupper($_GET['type']);

    if (
is_numeric($code) && (strlen($code) == 12)) {
      
$digit barcode_checksum('EAN-13',$code);
      echo (
"The checksum digit for $code is: $digit<br>This makes the total code $code$digit<br><img src='http://shared.sa007.nl/barcode/?code=$code$digit&type=EAN-13'>");
    } else {
      die(
"Not a correct code");
    }
  } else {
?>
<html>
  <head>
    <title>Generate a EAN-13 barcode checksum</title>
  </head>
  <body>
    <form>
      <table>
        <tr>
          <td>Code (12 digits):</td>
          <td><input type='text' name='code'></td>
        </tr>
        <tr>
          <td colspan='2' align='center'><input type='submit' value='Generate'></td>
        </tr>
      </table>
    </form>
  </body>
</html>
<?}?>