prepare('SELECT * FROM users WHERE username = ?'); $stmt->execute([$username]); $user = $stmt->fetch(); // DEBUGGING LINES echo ""; // END DEBUGGING LINES if ($user && password_verify($password, $user['password'])) { $_SESSION['user_id'] = $user['id']; $_SESSION['username'] = $user['username']; $_SESSION['role'] = $user['role']; // Redirect based on role if ($user['role'] === 'superadmin') { header('Location: admin.php'); exit; } else { // Redirect to a general user dashboard if needed header('Location: index.php'); exit; } } else { $error = 'Invalid username or password.'; } } catch (PDOException $e) { $error = 'Database error: ' . $e->getMessage(); } } } ?> Login - PicklePRO

PicklePRO Login