tee /var/www/bluewave/app/header.php > /dev/null <<'PHP'
BlueWave App
PHP
require __DIR__ . '/config.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
check_csrf();
$email = trim(strtolower($_POST['email'] ?? ''));
$pass = $_POST['password'] ?? '';
$stmt = $pdo->prepare('SELECT * FROM users WHERE email = ? LIMIT 1');
$stmt->execute([$email]);
$user = $stmt->fetch();
if ($user && password_verify($pass, $user['password_hash'])) {
$_SESSION['user'] = [
'id' => $user['id'],
'email' => $user['email'],
];
header('Location: /app/dashboard.php');
exit;
} else {
$error = 'Invalid login credentials';
}
}
include __DIR__ . '/header.php';
?>