hii, i am new to php and i wanna create a library management system with the help of php and procedure function in mysql so that i also got the security on my localmachine. bt i want to login the user with the help of access card and fetch all the details from mysql procedure. I already defined and created all the procedure in phpmyadmin bt i dont know how to write code in php to fetch that detail... so please help me on that......

Dani AI

Generated

For : break this into three clear pieces—how the card is read on the client, how the client sends a short token to the server, and how the server looks up and authenticates that token. ’s question is spot on: the implementation depends entirely on the reader type. Common cases:

  • Keyboard-wedge scanner: it just “types” the card ID into a focused input—easy to capture with plain JavaScript.
  • Serial/USB/HID readers: they often need a small native service, a vendor driver, or modern browser APIs (WebHID/WebUSB) to surface the UID to the page.
  • NFC on a phone or dedicated readers: use WebNFC or a companion app.

is correct to push PDO/MySQLi. Stored procedures are fine for encapsulating business rules, but they don’t replace proper authentication, hashing, or transport security. A practical server flow: receive a short card ID (not raw track data), call a stored procedure or prepared query that returns the user row or a status code, then check user state and start a secure session.

Example minimal server call with PDO:

<?php
$pdo = new PDO('mysql:host=127.0.0.1;dbname=library;charset=utf8mb4','user','pass',[PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION]);
$stmt = $pdo->prepare('CALL sp_get_user_by_card(:cardid)');
$stmt->bindValue(':cardid',$cardId,PDO::PARAM_STR);
$stmt->execute();
$user = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
?>

Security & practical tips: always use HTTPS, never store full card track data, store only the minimal token or a hashed verifier, use least-privilege DB accounts (EXECUTE only if using procedures), regenerate session IDs on login, and validate server-side even if the client supplies the card value. For local development, test with a keyboard-emulating reader or a small local bridge service—this avoids driver headaches while you build the PHP/PDO authentication flow.

Recommended Answers

All 2 Replies

why would you make login a MySQL procedure? am yet to see that kind of thing. Database should store basic information and password hash. use that to authenticate your user.

A word of advice is, use PDO or at least MySQLi.
If I have misunderstood you please comment!

Member Avatar for Member #120589

how is your card data read? is it to javascript?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.