Is it possible to read / access barcode scanner values โ€‹โ€‹using PHP and MySQL?

I am trying to enable a PHP website to recognize barcode input.

I will load the web page in the browser, the focus (cursor) is set to receive input in the text box.

I will have a barcode reader / scanner connected to a PC and scan the barcodes one by one using a scanner. Can barcode information be placed in the text box of a web page?

The important question is that how can I read the output from the scanner using PHP?

Please inform.

+4
source share
6 answers

There was a similar problem. Barcode scanners work like a keyboard, they just enter a string. Scanners can usually be configured to add a prefix or postfix for characters read from a barcode, often based on the type of barcode (may have a different configuration for code 39 than for code 128, for example.)

But the problem that we had in our last project was that the guys who developed the cashier system also set up a barcode scanner, and they put CTRL-B as a prefix in front of each barcode. In Firefox, this opens bookmarks, so you are trapped.

I mean, connecting the scanner is very simple, but you need to take care of the scanner configuration if there is a control character that can be captured by the browser or other software. On the other hand, it can be very useful, because you can enter a line feed after each barcode or something else that helps you split them.

Another important aspect in our case was time. Barcode scanners enter the character pretty quickly, but at least the one we had entered it one by one. Therefore, when we tested our functionality, there was a huge difference between a line pasted from the clipboard or a line scanned from a barcode. This was relevant for the Ajax-Calls we made (where in our case there were a lot of problems with this on the ZK website).

Hope this helps.

+9
source

This is not a programming issue per se. Barcode scanners work just like a keyboard, they enter scanned numbers.

The easiest way is to simply create a form with a text box and then publish it and process it using PHP code

+4
source

You cannot read the barcode using PHP because it is a server language, but the input will be on the client side.

What you can do is write a small program that receives the barcode and places it in the browser text box or sends it via GET / POST to your php script.

+3
source

As already mentioned, barcode scanners usually send only a sequence of characters to a computer, like a keyboard.

If you want to create an effective scanner, I would recommend using JavaScript and making

<input type="text"> 

which sends an AJAX barcode to the checked change or keyup event.

+2
source

Barcode scanners act just like a keyboard, in the sense that they will enter any barcode text into any focused field. I would create a form with an input text field. Submit this form to your php page to process input. Access the variable like this

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

depending on the form submission method

+1
source

Most barcode scanners emulate a keyboard.

So, if the input field has focus when you press the button on the scanner, the line with numbers will be written in the field, and you can save them.

+1
source

Source: https://habr.com/ru/post/1369443/


All Articles