mirror of
https://github.com/Alvin-Zilverstand/Spik-en-span.git
synced 2026-03-06 03:06:41 +01:00
add login, logout, ticket processing, and QR scanner functionality
This commit is contained in:
7
logout.php
Normal file
7
logout.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<!-- filepath: c:\xampp\htdocs\Spik-en-span\logout.php -->
|
||||
<?php
|
||||
session_start();
|
||||
session_destroy();
|
||||
header("Location: employee-login.html");
|
||||
exit();
|
||||
?>
|
||||
40
process_login.php
Normal file
40
process_login.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<!-- filepath: c:\xampp\htdocs\Spik-en-span\process_login.php -->
|
||||
<?php
|
||||
// Database connection
|
||||
$servername = "localhost";
|
||||
$username = "root";
|
||||
$password = "";
|
||||
$dbname = "spik_en_span";
|
||||
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
// Check connection
|
||||
if ($conn->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();
|
||||
?>
|
||||
36
process_ticket.php
Normal file
36
process_ticket.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<!-- filepath: c:\xampp\htdocs\Spik-en-span\process_ticket.php -->
|
||||
<?php
|
||||
// Database connection
|
||||
$servername = "localhost";
|
||||
$username = "root";
|
||||
$password = "";
|
||||
$dbname = "spik_en_span";
|
||||
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
// Check connection
|
||||
if ($conn->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();
|
||||
?>
|
||||
24
qr-scanner.php
Normal file
24
qr-scanner.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<!-- filepath: c:\xampp\htdocs\Spik-en-span\qr-scanner.php -->
|
||||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header("Location: employee-login.html");
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>QR Scanner</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container mt-5">
|
||||
<h1 class="text-center">QR Code Scanner</h1>
|
||||
<p class="text-center">This page is under construction.</p>
|
||||
<a href="logout.php" class="btn btn-danger">Logout</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user