File: //home/jibhires/brightsolutionsindia.com/images/register_machine_process.php
<?php
include 'db_connect.php';
require 'phpqrcode/qrlib.php'; // Include QR code library
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$machine_name = $_POST['machine_name'];
// Insert machine into the database
$stmt = $pdo->prepare("INSERT INTO machines (machine_name) VALUES (?)");
$stmt->execute([$machine_name]);
$machine_id = $pdo->lastInsertId();
// Generate the QR code for this machine
$qr_code = 'QR_' . $machine_id . '.png';
QRcode::png("Machine ID: $machine_id", "qrcodes/$qr_code");
// Update machine entry with QR code path
$stmt = $pdo->prepare("UPDATE machines SET qr_code = ? WHERE id = ?");
$stmt->execute([$qr_code, $machine_id]);
echo "Machine registered and QR code generated.";
}
?>