<?
  
include("functions.php");

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

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

    if (!
barcode_check($type$code)) die("Not a correct barcode");
    if (!
barcode_check_checksum($type$code)) die("Not a correct checksum");

    
$image binbartoimage(barcode_binbar($type$code),2,100);
    
header("Content-type: image/png");
    
imagepng($image);
  } else {
?>
<html>
  <head>
    <title>Create a barcode</title>
  </head>
  <body>
    <form>
      <table>
        <tr>
          <td>Code:</td>
          <td><input type='text' name='code'></td>
        </tr>
        <tr>
          <td>Type:</td>
          <td><select name='type'>
                <option value='EAN-13'>EAN-13</option>
                <option value='EAN-8'>EAN-8</option>
                <option value='EAN-2'>EAN-2</option>
                <option value='UPC-A'>UPC-A</option>
                <option value='ISBN'>ISBN</option>
          </select></td>
        </tr>
        <tr>
          <td colspan='2' align='center'><input type='submit' value='Generate'></td>
        </tr>
      </table>
    </form>
  </body>
</html>
<?}?>