CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Barcode program

  1. #1
    Join Date
    Dec 2008
    Posts
    27

    Barcode program

    is there a barcode program in PHP?

  2. #2
    Join Date
    Dec 2008
    Posts
    27

    Re: Barcode program

    i just found a PHP bracode program on the net, but how can i use it? how will i start? any idea?

  3. #3
    Join Date
    May 2002
    Posts
    10,943

    Re: Barcode program

    You are being very vague. What "barcode program" have you found? If we don't know what it is, how do you expect us to tell you how to use it? Have you even tried reading the provided documentation?

    What exactly are you trying to do with barcode?
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  4. #4
    Join Date
    Dec 2008
    Posts
    27

    Re: Barcode program

    i got this PHP Barcode Image Generator v1.0 [9/28/2000] available at this link http://www.sid6581.net/cs/php-script...e/barcode.phps

    how can i use this with a barcode reader? for example when the barcode reader reads a ceratin number it has its correspondent item.. how can i do that?

    i am currently using a form for the user to input product,

    but instead of inputting product i will use the barcode reader.

    heres my form:

    PHP Code:
    <?
        session_start();
        
        include("conn_db.php");
        
        
        $call = mysql_query("SELECT invoice_no FROM cash_invoice");
        
        while($row = mysql_fetch_array($call))
        {
            $invoice_no = $row["invoice_no"];
            if($invoice_no==" ")
            {
                $invoice_no = 1;
            }
            else
            {
                $invoice_no = invoice_no + 1;
            }
        }
        
        
        if(isset($_POST['save']))
        {
            include("insert_invoice.php");
        }
    ?>
    <html>
    <head>
        <title>Cash Invoice</title>
        
        <script type="text/javascript" src="validator.js"></script>
           <script type="text/javascript" src="cash_invoice.js"></script>
        <link type="text/css" href="css/format.css" rel="stylesheet"/>
    </head>
    <body onLoad="startCalc()">
    <form name="form1" action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
      <table width="568" border="1" cellpadding="0" cellspacing="0">
        <tr>
          <td height="125" colspan="9"><table width="561" height="111" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td colspan="9"><table width="565" bgcolor="#99CCFF" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="472" height="25" class="main"><b>&nbsp;Cash Invoice</b></td>
                    <td width="93" height="25" class="sonum">No.
                      <input name="invoice_no" type="text"  maxlength="5" onChange="checknum()" value="<?php if(isset($_POST['invoice_no'])){ echo $_POST['invoice_no'];} ?>" size="4"></td>
                  </tr>
              </table></td>
            </tr>
            <tr>
              <td width="107" height="22" align="left" class="txtformat1">&nbsp;Customer:</td>
              <td width="458"><input name="customer" type="text" class="txtreq" value="<?php if(isset($_POST['customer'])){ echo $_POST['customer'];} ?>" size="50"></td>
            </tr>
            <tr>
              <td height="22" align="left" class="txtformat1">&nbsp;Address:</td>
              <td><input name="address" type="text" class="txtreq" value="<?php if(isset($_POST['address'])){ echo $_POST['address'];} ?>" size="50"></td>
            </tr>
            <tr>
              <td height="22" align="left" class="txtformat1">&nbsp;Bus. Style:</td>
              <td><input name="bus_style" type="text" class="txtreq" value="<?php if(isset($_POST['bus_style'])){ echo $_POST['bus_style'];} ?>" size="50"></td>
            </tr>
            <tr>
              <td height="22" align="left" class="txtformat1">&nbsp;TIN:</td>
              <td><input name="tin" type="text" class="txtreq" value="<?php if(isset($_POST['tin'])){ echo $_POST['tin'];} ?>" size="15"></td>
            </tr>
          </table></td>
        </tr>
        <tr>
          <td colspan="9"><table width="266" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" align="center">
              <tr>
                <td width="140" height="19" align="center" class="header">Articles</td>
                <td width="26" colspan="-1" align="center" class="header">Qty</td>
                <td width="40" align="center" class="header">Unit Price </td>
                <td width="40" align="center" class="header">Total</td>
              </tr>
              <tr>
                <td><input name="prod_id1" type="hidden" value="<?php if(isset($_POST['prod_id1'])){ echo $_POST['prod_id1'];} ?>">
                    <input name="articlesa1" type="text" class="txtreq" size="45" id="rowa1" value="<?php if(isset($_POST['articlesa1'])){ echo $_POST['articlesa1'];} ?>"readonly/></td>
                <td width="26" colspan="-1"><input name="qtya1" type="text" class="txtreq" onBlur="isNum(this.value)" onChange="checkqty()" size="5" maxlength="7" value="<?php if(isset($_POST['qtya1'])){ echo $_POST['qtya1'];} ?>"/></td>
                <td><input name="unitpricea1" type="text" class="txtreq" size="10" style="text-align:right" value="<?php if(isset($_POST['unitpricea1'])){ echo $_POST['unitpricea1'];} ?>"/></td>
                <td><input name="prtotal1" type="text" class="txtreq" size="10"  style="text-align:right" readonly value="<?php if(isset($_POST['prtotal1'])){ echo $_POST['prtotal1'];} ?>"/></td>
                <td align="center"><input name="button" type="button" class="clear" value="C" onClick="clear1()"></td>
              </tr>
              <tr>
                <td><input name="prod_id2" type="hidden" id="rowa2" value="<?php if(isset($_POST['prod_id2'])){ echo $_POST['prod_id2'];} ?>">
                <input name="articlesa2" type="text" class="txtnotreq" value="<?php if(isset($_POST['articlesa2'])){ echo $_POST['articlesa2'];} ?>" size="45" readonly/></td>
                <td colspan="-1"><input name="qtya2" type="text" class="txtnotreq" onBlur="isNum(this.value)" value="<?php if(isset($_POST['qtya2'])){ echo $_POST['qtya2'];} ?>" size="5" maxlength="7"/></td>
                <td><input name="unitpricea2" type="text" class="txtnotreq" value="<?php if(isset($_POST['unitpricea2'])){ echo $_POST['unitpricea2'];} ?>" size="10" style="text-align:right"></td>
                <td><input name="prtotal2" type="text" class="txtnotreq" value="<?php if(isset($_POST['prtotal2'])){ echo $_POST['prtotal2'];} ?>" size="10" style="text-align:right" readonly/></td>
                <td align="center"><input name="button" type="button" class="clear" value="C" onClick="clear2()"></td>
              </tr>
              <tr>
                <td><input name="prod_id3" type="hidden" id="rowa3" value="<?php if(isset($_POST['prod_id3'])){ echo $_POST['prod_id3'];} ?>">
                <input name="articlesa3" type="text" class="txtnotreq" value="<?php if(isset($_POST['articlesa3'])){ echo $_POST['articlesa3'];} ?>" size="45" readonly/></td>
                <td colspan="-1"><input name="qtya3" type="text" class="txtnotreq" onBlur="isNum(this.value)" value="<?php if(isset($_POST['qtya3'])){ echo $_POST['qtya3'];} ?>" size="5" maxlength="7" /></td>
                <td><input name="unitpricea3" type="text" class="txtnotreq" value="<?php if(isset($_POST['unitpricea3'])){ echo $_POST['unitpricea3'];} ?>" size="10" style="text-align:right"/></td>
                <td><input name="prtotal3" type="text" class="txtnotreq" value="<?php if(isset($_POST['prtotal3'])){ echo $_POST['prtotal3'];} ?>" size="10" style="text-align:right" readonly/></td>
                <td><input name="button3" type="button" class="clear" value="C" onClick="clear3()"></td>
              </tr>
              <tr>
                <td><input name="prod_id4" type="hidden" id="rowa4" value="<?php if(isset($_POST['prod_id4'])){ echo $_POST['prod_id4'];} ?>">
                    <input name="articlesa4" type="text" class="txtnotreq" value="<?php if(isset($_POST['articlesa4'])){ echo $_POST['articlesa4'];} ?>" size="45" readonly/></td>
                <td colspan="-1"><input name="qtya4" type="text" class="txtnotreq" onBlur="isNum(this.value)" value="<?php if(isset($_POST['qtya4'])){ echo $_POST['qtya4'];} ?>" size="5" maxlength="7" /></td>
                <td><input name="unitpricea4" type="text" class="txtnotreq" value="<?php if(isset($_POST['unitpricea4'])){ echo $_POST['unitpricea4'];} ?>" size="10" style="text-align:right"/></td>
                <td><input name="prtotal4" type="text" class="txtnotreq" value="<?php if(isset($_POST['prtotal4'])){ echo $_POST['prtotal4'];} ?>" size="10" style="text-align:right" readonly/></td>
                <td><input name="button11" type="button" class="clear" value="C" onClick="clear4()"></td>
              </tr>
              <tr>
                <td><input name="prod_id5" type="hidden" id="rowa5" value="<?php if(isset($_POST['prod_id5'])){ echo $_POST['prod_id5'];} ?>">
                    <input name="articlesa5" type="text" class="txtnotreq" value="<?php if(isset($_POST['articlesa5'])){ echo $_POST['articlesa5'];} ?>" size="45" readonly/></td>
                <td colspan="-1"><input name="qtya5" type="text" class="txtnotreq" onBlur="isNum(this.value)" value="<?php if(isset($_POST['qtya5'])){ echo $_POST['qtya5'];} ?>" size="5" maxlength="7" /></td>
                <td><input name="unitpricea5" type="text" class="txtnotreq" value="<?php if(isset($_POST['unitpricea5'])){ echo $_POST['unitpricea5'];} ?>" size="10" style="text-align:right"/></td>
                <td><input name="prtotal5" type="text" class="txtnotreq" value="<?php if(isset($_POST['prtotal5'])){ echo $_POST['prtotal5'];} ?>" size="10" style="text-align:right" readonly/></td>
                <td><input name="button4" type="button" class="clear" value="C" onClick="clear5()"></td>
              </tr>
              <tr>
                <td><input name="prod_id6" type="hidden" id="rowa6" value="<?php if(isset($_POST['prod_id6'])){ echo $_POST['prod_id6'];} ?>">
                    <input name="articlesa6" type="text" class="txtnotreq" value="<?php if(isset($_POST['articlesa6'])){ echo $_POST['articlesa6'];} ?>" size="45" readonly/></td>
                <td colspan="-1"><input name="qtya6" type="text" class="txtnotreq" onBlur="isNum(this.value)" value="<?php if(isset($_POST['qtya6'])){ echo $_POST['qtya6'];} ?>" size="5" maxlength="7"/></td>
                <td><input name="unitpricea6" type="text" class="txtnotreq" value="<?php if(isset($_POST['unitpricea6'])){ echo $_POST['unitpricea6'];} ?>" size="10" style="text-align:right"/></td>
                <td><input name="prtotal6" type="text" class="txtnotreq" value="<?php if(isset($_POST['prtotal6'])){ echo $_POST['prtotal6'];} ?>" size="10" style="text-align:right" readonly/></td>
                <td><input name="button5" type="button" class="clear" value="C" onClick="clear6()"></td>
              </tr>
              <tr>
                <td><input name="prod_id7" type="hidden" id="rowa7" value="<?php if(isset($_POST['prod_id7'])){ echo $_POST['prod_id7'];} ?>">
                    <input name="articlesa7" type="text" class="txtnotreq" value="<?php if(isset($_POST['articlesa7'])){ echo $_POST['articlesa7'];} ?>" size="45" readonly/></td>
                <td colspan="-1"><input name="qtya7" type="text" class="txtnotreq" onBlur="isNum(this.value)" value="<?php if(isset($_POST['qtya7'])){ echo $_POST['qtya7'];} ?>" size="5" maxlength="7"/></td>
                <td><input name="unitpricea7" type="text" class="txtnotreq" value="<?php if(isset($_POST['unitpricea7'])){ echo $_POST['unitpricea7'];} ?>" size="10" style="text-align:right"/></td>
                <td><input name="prtotal7" type="text" class="txtnotreq" value="<?php if(isset($_POST['prtotal7'])){ echo $_POST['prtotal7'];} ?>" size="10" style="text-align:right" readonly/></td>
                <td><input name="button6" type="button" class="clear" value="C" onClick="clear7()"></td>
              </tr>
              <tr>
                <td><input name="prod_id8" type="hidden" id="rowa8" value="<?php if(isset($_POST['prod_id8'])){ echo $_POST['prod_id8'];} ?>">
                    <input name="articlesa8" type="text" class="txtnotreq" value="<?php if(isset($_POST['articlesa8'])){ echo $_POST['articlesa8'];} ?>" size="45" readonly/></td>
                <td colspan="-1"><input name="qtya8" type="text" class="txtnotreq" onBlur="isNum(this.value)" value="<?php if(isset($_POST['qtya8'])){ echo $_POST['qtya8'];} ?>" size="5" maxlength="7"/></td>
                <td><input name="unitpricea8" type="text" class="txtnotreq" value="<?php if(isset($_POST['unitpricea8'])){ echo $_POST['unitpricea8'];} ?>" size="10" style="text-align:right"/></td>
                <td><input name="prtotal8" type="text" class="txtnotreq" value="<?php if(isset($_POST['prtotal8'])){ echo $_POST['prtotal8'];} ?>" size="10" style="text-align:right" readonly/></td>
                <td><input name="button7" type="button" class="clear" value="C" onClick="clear8()"></td>
              </tr>
              <tr>
                <td><input name="prod_id9" type="hidden" id="rowa9" value="<?php if(isset($_POST['prod_id9'])){ echo $_POST['prod_id9'];} ?>">
                    <input name="articlesa9" type="text" class="txtnotreq" value="<?php if(isset($_POST['articlesa9'])){ echo $_POST['articlesa9'];} ?>" size="45" readonly/></td>
                <td colspan="-1"><input name="qtya9" type="text" class="txtnotreq" onBlur="isNum(this.value)" value="<?php if(isset($_POST['qtya9'])){ echo $_POST['qtya9'];} ?>" size="5" maxlength="7"/></td>
                <td><input name="unitpricea9" type="text" class="txtnotreq" value="<?php if(isset($_POST['unitpricea9'])){ echo $_POST['unitpricea9'];} ?>" size="10" style="text-align:right"/></td>
                <td><input name="prtotal9" type="text" class="txtnotreq" value="<?php if(isset($_POST['prtotal9'])){ echo $_POST['prtotal9'];} ?>" size="10" style="text-align:right" readonly/></td>
                <td><input name="button8" type="button" class="clear" value="C" onClick="clear9()"></td>
              </tr>
                <td height="19" class="total" align="left"><input name="product" type="button" class="btn" id="PRODUCT2" value="Products List" onClick="javascript:window.open('popup_products_list.php','','height=200px,width=550px,top=300,left=250')"></td>
                <td>&nbsp;</td>
              </tr>
            </table>
              
              </div></td>
        </tr>
        <table width="568" border="1" cellpadding="0" cellspacing="0">
        <tr>
          <td width="190" height="19" align="right" bgcolor="#FFFFFF" class="total">Total Sales&nbsp;</td>
          <td width="105" height="19"><input name="total_sales" type="text" class="totalbox" id="total_sales" value="<?php if(isset($_POST['total_sales'])){ echo $_POST['total_sales'];} ?>" size="15" style="text-align:right" readonly></td>
          <td width="94" height="19" align="right" bgcolor="#FFFFFF" class="total">Prepared By:&nbsp;</td>
          <td width="169" height="19"><input name="prepared_by" type="text" class="textbox" size="25" value="<?=$_SESSION['username']?>" readonly></td>
        </tr>
        <tr>
          <td height="19" align="right" bgcolor="#FFFFFF" class="total">12% Value Added Tax&nbsp;</td>
          <td height="19"><input name="vat" type="text" class="totalbox" id="vat" value="<?php if(isset($_POST['vat'])){ echo $_POST['vat'];} ?>" size="15" style="text-align:right" readonly></td>
            <input type="hidden" name="vatno" value="<?=$tax;?>">
          <td height="19" align="right" bgcolor="#FFFFFF" class="total">Approved By:&nbsp;</td>
          <td height="19"><input name="approved_by" type="text" class="textbox" size="25" value="<?php if(isset($_POST['approved_by'])){ echo $_POST['approved_by'];} ?>"></td>
        </tr>
        <tr>
          <td height="19" align="right" bgcolor="#FFFFFF" class="total">Total Amount Payable&nbsp;</td>
          <td height="19"><input name="products" type="text" class="totalbox" id="products" value="<?php if(isset($_POST['products'])){ echo $_POST['products'];} ?>" size="15" style="text-align:right" readonly></td>
          <td height="19" align="right" bgcolor="#FFFFFF" class="total">Released By:&nbsp;</td>
          <td height="19"><input name="released_by" type="text" class="textbox" size="25" value="<?php if(isset($_POST['released_by'])){ echo $_POST['released_by'];} ?>"></td>
        </tr>
        </table>
        <table width="568" border="1" cellpadding="0" cellspacing="0">
        <tr>
          <td align="right" height="19"><input name="save" type="submit" class="btn" value="Create" onClick="validate()"/><input name="reset" type="reset" onClick="reset" class="btn" value="Clear"/></td>
        </tr>
      </table>
    </form>
    </body>
    </html>

    <script  language="javascript">
    i=document.form1;

    function validate()
    {
        if(i.invoice_no.value=="" && i.customer.value=="" && i.articlesa1.value=="" && i.qtya1.value=="" && i.unitpricea1.value=="")
        {
            alert("Please Fill Up the Form.");
            return false;
        }
        
        else if(i.invoice_no.value=="")
        {
            alert("Please Enter Invoice No.");
            return false;
        }
        if(i.customer.value=="")
        {
            alert("Please Enter Customer.");
            return false;
        }
        if(i.articlesa1.value=="")
        {
            alert("You Must Select a Product.");
            return false;
        }
        if(i.qtya1.value=="")
        {
            alert("Please Enter Product Quantity.");
            return false;
        }
        if(i.unitpricea1.value=="")
        {
            alert("Please Enter Product Price.");
            return false;
        }
        else
        {
        i.submit();
            }    
    }

    function checknum()
    {
        var txt=i.invoice_no.value;
        var num = "0123456789.";
        var strChar;
        var dig = true;

        if (txt.length == 0) return false;
        
        for (a = 0; a < txt.length && dig == true; a++)
        {
            strChar = txt.charAt(a);
            if (num.indexOf(strChar) == -1)
            {
                dig=false;
            }
            else
            {    
                dig=true;
            }
        }
        if(dig==false)
        {
            alert("Invalid Invoice No.");
        }    
    }
    </script>
    Last edited by PeejAvery; January 16th, 2009 at 08:28 AM. Reason: Added PHP tags.

  5. #5
    Join Date
    May 2002
    Posts
    10,943

    Re: Barcode program

    A barcode scanner simply acts as a keyboard. It will type exactly what the barcode says, and then simulate the return key. In order to read it, all you need is an input that keeps focus. Since it automatically simulates the return key, if you put it in a form, it will submit the form upon reading the barcode.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  6. #6
    Join Date
    Dec 2008
    Posts
    27

    Re: Barcode program

    MOD what do you mean by "simulate the return key"? Is there no need for me to use the PHP Barcode Image Generator v1.0 program?

  7. #7
    Join Date
    May 2002
    Posts
    10,943

    Re: Barcode program

    If you want to generate barcodes, then yes, you will need a generator. But, if you are just attempting to read them, then no.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured