From 3a447d9f0e247e419e503226970d0a082e33218f Mon Sep 17 00:00:00 2001 From: vista-man <524715@vistacollege.nl> Date: Thu, 3 Apr 2025 12:05:14 +0200 Subject: [PATCH] add login, logout, ticket processing, and QR scanner functionality --- logout.php | 7 +++++++ process_login.php | 40 ++++++++++++++++++++++++++++++++++++++++ process_ticket.php | 36 ++++++++++++++++++++++++++++++++++++ qr-scanner.php | 24 ++++++++++++++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 logout.php create mode 100644 process_login.php create mode 100644 process_ticket.php create mode 100644 qr-scanner.php diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..b154b20 --- /dev/null +++ b/logout.php @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/process_login.php b/process_login.php new file mode 100644 index 0000000..8a6d60e --- /dev/null +++ b/process_login.php @@ -0,0 +1,40 @@ + +connect_error) { + die("Connection failed: " . $conn->connect_error); +} + +// Retrieve form data +$username = $_POST['username']; +$password = $_POST['password']; + +// Validate credentials +$sql = "SELECT id, password_hash FROM employees WHERE username = ?"; +$stmt = $conn->prepare($sql); +$stmt->bind_param("s", $username); +$stmt->execute(); +$stmt->bind_result($user_id, $password_hash); +$stmt->fetch(); + +if ($password_hash && password_verify($password, $password_hash)) { + // Start session and store user ID + session_start(); + $_SESSION['user_id'] = $user_id; + echo "Login successful!"; + header("Location: qr-scanner.html"); // Redirect to QR scanner page +} else { + echo "Invalid login credentials."; +} + +$stmt->close(); +$conn->close(); +?> \ No newline at end of file diff --git a/process_ticket.php b/process_ticket.php new file mode 100644 index 0000000..cf77030 --- /dev/null +++ b/process_ticket.php @@ -0,0 +1,36 @@ + +connect_error) { + die("Connection failed: " . $conn->connect_error); +} + +// Retrieve form data +$name = $_POST['name']; +$email = $_POST['email']; +$category = $_POST['category']; +$quantity = $_POST['quantity']; +$ticket_id = "TICKET-" . time(); + +// Insert ticket into database +$sql = "INSERT INTO tickets (ticket_id, name, email, category, quantity) VALUES (?, ?, ?, ?, ?)"; +$stmt = $conn->prepare($sql); +$stmt->bind_param("ssssi", $ticket_id, $name, $email, $category, $quantity); + +if ($stmt->execute()) { + echo "Ticket successfully purchased! Your Ticket ID is: " . $ticket_id; +} else { + echo "Error: " . $stmt->error; +} + +$stmt->close(); +$conn->close(); +?> \ No newline at end of file diff --git a/qr-scanner.php b/qr-scanner.php new file mode 100644 index 0000000..8cf8c2d --- /dev/null +++ b/qr-scanner.php @@ -0,0 +1,24 @@ + + + + + + + + QR Scanner + + + +
+

QR Code Scanner

+

This page is under construction.

+ Logout +
+ + \ No newline at end of file