PHP / MySQL POS Solution Incorporating Barcode Scanner into Website Form Input (Australian Solution)

Posted on 2007-12-04
Last Modified: 2013-12-12
Looking for advice from php/MySQL devs who have experience in integrating barcode scanners into php product ordering systems.

The scanners are intended to be used by website staff for point of sale on location. The user navigates to the new order page, scans the item and the order form populates all fields with the item's details.

This psudo POS system is for an Australian business. So any hardware, has to be available in AU. The entire system must be php/mysql based, so solutions such as myob will be ignored.

Thanks in advance for taking any time composing replies.
Question by:v2Media
  • 6
  • 2
LVL 17

Assisted Solution

psimation earned 100 total points
ID: 20409369
I havn't worked with barcode scanners for quite a while, but "back in the day", the barcode scanners we used to work with were merely "keyboard" interfaces - ie. the barcode scanner would "convert" the barcode into characters and then simply send it via the keyboard interface as if it were typed in in the first place.
I am guessing that most barcode scanners will come with software (or firmaware) that will already be capable of "understanding" most standards already , and the bundled software will allow you to further add/edit onto the standard values if you require.

Thus, if things still work the same, you won't need to do any coding in order to use a barcode scanner on your website, but you may need to do some coding if you want to add some extra descriptions to the standard barcode values ( usually they are only number sequence printed below barcodes as you see them on packages) - but this should be pretty straigh forward; you could simply create a lookup table holding your descriptions paired with the numerical values, and when you scan something, you replace the numbers with the description.
LVL 42

Assisted Solution

by:Rob Jurd, EE MVE
Rob Jurd, EE MVE earned 400 total points
ID: 20414818
TO add to psimation, I see this as 3 parts, the webpage, the database, and the user input.  
The webpage (php form) is where the user puts a barcode into a textbox and submits the form.
The barcode is used in a database lookup to return the other information.  How the barcode is entered shouldn't matter (ie user input or barcode scanner).
Most barcode scanners these days have the scanner send escape keys such as newline after a barcode is scanned, so whether the user types the barcode manually and presses enter or a barcode is scanned, the form won't know the difference.
I know these guys sell a quality barcode scanner: but there are heaps of different options such as bluetooth wireless but I reckon you only need the basic scanner as long as it can send the escape codes (prevent the user having to press enter after every scan).
Where are you up to in the project and what part in particular do you require advice?
LVL 19

Author Comment

ID: 20415360
The project is completed; the client wants this as an additional feature. My ignorance of how scanners work is the problem, and finding some off-the-shelf code to integrate them into a website.

There's a massive hole in the advice given so far. I realise that scanners are basic input devices that translate barcodes into numeric sequences and a trailing \r\n. However in order for this input to work, there's several processes that have to be completed to get to that stage:

Modify product labels to feature barcodes
Inventory scan to associate a barcode with a product

These are the processes which obviously require additional forms for data entry, item selection and scripting for item barcode printing. From what the both of you have posted, the scanner is nothing more than emulated keyboard entry. So that leaves incorporating the barcode into the product label printing.

So, the forms/processing required would be something along these lines yes?

1. Barcode generation (prolly pdf)

2. Product selection to printer form for printing the required number of barcodes for each item selected (all items for initial print run).

3. Forms for scanning in the initial code to product associations (auto submits and iterates to next item).

There's probably a bunch of other things that these systems use to minimise labour, such as printing a catalog of item thumbnails over barcodes for manual scanning when label cannot be scanned....

I realise this whole concept of barcode scanning is simple, but from my experience, the devil is in the detail...

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 20415429
1. PDF yes it will need to be so that when it is printed it will be clear. (I have php code for this as well) as we generate barcodes so that they can be put on our product.

2. I'm guessing this is selecting a product that you want to print barcodes for and php will print out a form full of labels (barcodes) to stick on the product?

3. Would this be a form that would bring up all your product items that do not currently have a barcode associated?  If so, then you find the product the page is asking for and then scan the barcode that's on the item and associate the barcode in your system with that product code?
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 20415456
To add have a look at PHP-Barcode which can create html images from php

eg. this is all the code you would need with their include file:

$code = (get_magic_quotes_gpc()) ? stripslashes(getvar('code')) : getvar('code');
// encoding - this will guess EAN or UPC
// scale
// mode (type)

Open in new window

LVL 42

Accepted Solution

Rob Jurd, EE MVE earned 400 total points
ID: 20415537
PHP-Barcode 0.3pl1

PHP-Barcode generates
  - Barcode-Images using libgd (png, jpg,gif),
  - HTML-Images (using 1x1 pixel and html-table)
  - silly Text-Barcodes

PHP-Barcode encodes using
  - a built-in EAN-13/ISBN Encoder
  - genbarcode (by Folke Ashberg), a command line
    barcode-encoder which uses GNU-Barcode
    genbarcode can encode EAN-13, EAN-8, UPC, ISBN, 39, 128(a,b,c),
    I25, 128RAW, CBR, MSI, PLS
    genbarcode is available at 

(C) 2001,2002,2003,2004 by Folke Ashberg <>

The newest version can be found at
LVL 19

Author Comment

ID: 20415732
Thx for ur help tagit. I get the impression there's nothing available in a nice, neat package that will do it all, which is what I was really hoping for. This will more than likely be a one-time project. I really didn't want to have to put together all the different pieces into a coherent whole that's usable via a website gui. It seems that's what's required tho.
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 20415736
this is a command line barcode generator for creating eps files:
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 20415756
here is the code i use to create the eps:
		echo "$code<br>";
		$res = barcode_encode_ean($code);
		if ($res["valid"]) {
			// Outputs all the result of the shellcommand, and returns
			// the last output line into $last_line. Stores the return value
			// of the shell command in $retval.
			// 931618812345
			//create the directory
			if (!is_dir("eps")) {
				mkdir("./eps/",0777, true);
			if (!is_dir("./eps/$sid")) {
				mkdir("./eps/$sid",0777, true);
			if (!strcmp($encoding,"any")==0) {
				$last_line = system("barcode -o .\\eps\\$sid\\$ean.eps -b $ean -u mm -E -e $encoding -g $w" . "x" . "$h+10+10 -p $w" . "x$h", $retval);
			else {
				$last_line = system("barcode -o .\\eps\\$sid\\$ean.eps -b $ean 0u mm -E -g $w" . "x$h", $retval);
			if (false) {
				echo "$retval -> $last_line<br>";
			echo "
			Created EPS barcode file: <a href=\"eps/$sid/$ean.eps\">$ean.eps</a>

Open in new window


Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Advice and best practice  SQLite3 Database using PHP 2 47
php extract($_REQUEST) 5 46
ebay api to see some data about my customers 2 28
PHP AJAX Wordpress 9 19
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
All of the resources available today make learning a new digital media easier than ever-- if you know where to begin. This is a clear, simple guide to a few of the basic digital art mediums and how to begin learning them on your own.
The viewer will learn how to count occurrences of each item in an array.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

775 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question