How to link access card reader with PHP?
I want to use an access card reader with开发者_Python百科 PHP. I am doing this to monitor attendance at a college. Is there any intermediate technology which can be used to take the readings from access card reader to the database?
I know I'm late to this question, but I'm building a similar product. This is in fact possible with a simple card reader contrary to the other answers. USB based card readers act as simple keyboard input devices, so when a person is ready to swipe, make sure that a text box is in focus and then swipe.
From there, you can take the keyboard data that is read and push it to a hidden input box and then process it server side (or even client side with some JavaScript). I'm using a lot of jQuery to make things a little more seamless on the client side, so it's not as straightforward as I'm describing, but it's definitely possible.
Here's a .NET example that you can use to port to PHP
EDIT: 2/2016
I created a GitHub Gist with a very simple jQuery implementation.
I've worked with a bar code scanner before, and I know the one we had acted like a keyboard and basically "typed" in what it read, and hit enter. Maybe your card reader can or does do something similar?
If that's the case, you could set up a very simple form with a text input and with JavaScript, auto-focus on the input. Then have the form submit to a PHP script that logs what it's given.
I have seen a card scanner used as a time-keeping device once. My company had it on a computer, with a page with a current status full-screen on the monitor. When someone swiped their card, it would fire off a Perl program and update the database. I think the page was set to refresh every so many seconds.
Hope something I've said sparks an idea for you.
Likely, this cannot easily be integrated with PHP. Perhaps for a backend API interface via JSON or something, but the card reader interface will need to be something that can run and work with physical hardware.
Unless you mean, you already have the readings and want to put it in a database...PHP can parse it.
If a software was provided along with the reader, you may want to refer to its documentation on how it outputs the data. Let's say, if it gives out a CSV, you may want to parse the CSV and store it in the database, which later can be processed by PHP.
Some reader software are capable of directly writing to the database. Again, it all depends on what brand and model of reader you have got.
I believe some of the other guys are right as well as the others. But you also have to remember that some card readers are 3-4 tier if not 1 or 2. You can simply use it as a "keyboard" by a simple swipe but if anything it's going to only read the first line and that's it.
精彩评论