prepare("SELECT id, username, password, role FROM users WHERE username = ?"); $stmt->execute([$username]); $user = $stmt->fetch(); if ($user && password_verify($password, $user['password'])) { // Password is correct, start a new session $_SESSION['user_id'] = $user['id']; $_SESSION['username'] = $user['username']; $_SESSION['role'] = $user['role']; // Redirect to the main page header("Location: index.php"); exit; } else { $error = 'Invalid username or password.'; } } catch (PDOException $e) { $error = 'Database error. Please try again later.'; } } } ?> Login - Psychological Testing System

Login

Don't have an account? Register here