I am currently creating a QR Code generator, however, I am stuck at some point where I don't know how will I connect the details of my database to the QR Code. What I mean is I wanted to use the field idNum
in my database to be the text generated in my QR code. Here are the samples of my code:
include('phpqrcode/qrlib.php');
$text="Hello";
$path = 'qrcodes/';
$file = $path.uniqid().".png";
$ecc = 'L'; // error correction capability
$pixel_Size = 170;
$frame_size = 10;
QRcode::png($text, $file, $ecc, $pixel_Size, $frame_Size);
Instead of text "Hello", I want to display the idNum
in my database. How?
Here is also an attempted code that I have created, however when I scan the QR code, there is no value being displayed.
$connection = mysqli_connect("localhost", "root", "", "db_bakascts") or die(mysqli_error($mysqli));
$id=isset($_POST['idNum']);
$sql = "SELECT * FROM tb_usersreg WHERE idNum='$id'";
$result=mysqli_query($connection,$sql) or die("Error");
$width = "250";
$height = "250";
$url = "https://chart.googleapis.com/chart?cht=qr&chs={$width}x{$height}&chl={$id}";
$qr["img"] = $url;