Is it possible to read/access the bar-code scanner values using PHP & MySQL?

倖福魔咒の 提交于 2019-11-29 00:38:12

Had a similar problem. Barcode scanners work like keyboards, they just enter a string. The scanners can usually be configured so that they add a prefix or a postfix to the characters read from the barcode, often on a per barcode-type basis (can have different config for Code 39 than for Code 128 e.g.)

But, a problem that we had in our last project was, that the guys that developed the cashier system also configured the barcode scanner and they put a CTRL-B as a prefix in front of every barcode. In Firefox, this opens up the Bookmarks and so you´re trapped.

What I mean is, connecting the scanner is easy, but you have to care for the configuration of the scanner if there are control character that might be captured by the browser or some other software. On the other hand, this can be very useful cause you can enter a linefeed after each barcode or something else that helps you separate them.

Another important aspect in our case was the timing. The barcode scanners enter the character quite fast, but - at least the one we had - entered it one by one. So when we tested our functionality, there was a huge difference between the string pasted from the clipboard or the string scanned from the barcode. This was relevant for Ajax-Calls we did (where in our case, a ZK-based website had lots of trouble with that).

Hope that helps.

This is not a programming question per se. Bar code scanners work just like a keyboard, they input the digits scanned.

The easiest way is to just create a form with a textbox and then post it and handle it with your PHP code

You cannot read the barcode using PHP, because it's a serverside language, but the input would be client-side.

What you could do, is write a little program which gets the barcode and puts it into your browser textbox or sends it via GET / POST to your php script.

As already stated, bar code scanners usually only send a sequence of characters to the computer, much like a keyboard.

If you want to make an efficient scanner, I would recommend using JavaScript and making an

<input type="text"> 

that sends the bar code by AJAX on a validated change or keyup-event.

Barcode scanners act just like a keyboard in the sense that they will input whatever barcode text into whatever focused field you have. I would set up a form with a text box for input. Submit said form to a php page to process the input. Access the variable like so

$_GET['variable'] or $_POST['variable']

depending on your form post method

Most barcode scanners emulate a keyboard.

So as long as the input field has focus when the button is pressed on the scanner, a string with numbers will be written to the field and you can save those.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!