This commit is contained in:
EspenVista
2025-04-03 10:55:20 +01:00
parent 56c545021f
commit ff34c09abe
3 changed files with 15 additions and 15 deletions

View File

@@ -1,8 +1,8 @@
-- Create the database
CREATE DATABASE IF NOT EXISTS spik_en_span;
USE spik_en_span;
-- Table for storing ticket information
CREATE TABLE tickets (
id INT AUTO_INCREMENT PRIMARY KEY,
ticket_id VARCHAR(255) NOT NULL UNIQUE,
@@ -13,15 +13,15 @@ CREATE TABLE tickets (
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Table for storing employee login credentials
CREATE TABLE employees (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) NOT NULL UNIQUE,
password_hash VARCHAR(255) NOT NULL, -- Store hashed passwords
password_hash VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Table for storing scanned ticket logs
CREATE TABLE scanned_tickets (
id INT AUTO_INCREMENT PRIMARY KEY,
ticket_id VARCHAR(255) NOT NULL,
@@ -30,7 +30,7 @@ CREATE TABLE scanned_tickets (
UNIQUE (ticket_id)
);
-- Table for storing unique strings for users
CREATE TABLE unique_strings (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
@@ -39,7 +39,7 @@ CREATE TABLE unique_strings (
FOREIGN KEY (user_id) REFERENCES employees(id) ON DELETE CASCADE
);
-- Trigger to automatically generate a unique 6-character alphanumeric string for each user
DELIMITER $$
CREATE TRIGGER generate_unique_code
AFTER INSERT ON employees
@@ -51,6 +51,6 @@ BEGIN
END$$
DELIMITER ;
-- Insert a default employee account (username: admin, password: password)
INSERT INTO employees (username, password_hash)
VALUES ('admin', SHA2('password', 256)); -- Replace with a secure password hashing method
VALUES ('admin', SHA2('password', 256));

View File

@@ -32,10 +32,10 @@
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
// Placeholder for authentication logic
if (username === 'admin' && password === 'password') {
alert('Succesvol ingelogd!');
window.location.href = 'qr-scanner.html'; // Redirect to QR scanner page
window.location.href = 'qr-scanner.html';
} else {
alert('Ongeldige inloggegevens.');
}

View File

@@ -6,15 +6,15 @@ document.getElementById('ticketForm').addEventListener('submit', function (e) {
const category = document.getElementById('ticketCategory').value;
const quantity = document.getElementById('ticketQuantity').value;
// Generate a unique ticket ID (for simplicity, using timestamp)
const ticketId = `TICKET-${Date.now()}`;
// Generate QR code content
const qrContent = `Name: ${name}, Email: ${email}, Category: ${category}, Quantity: ${quantity}, Ticket ID: ${ticketId}`;
// Display QR code (using a library like QRCode.js)
const qrCodeContainer = document.getElementById('qrCodeContainer');
qrCodeContainer.innerHTML = ''; // Clear previous QR code
qrCodeContainer.innerHTML = '';
const qrCode = new QRCode(qrCodeContainer, {
text: qrContent,
width: 200,