<?php
// Password reset script for live deployment
require_once 'includes/db.php';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $email = $_POST['email'] ?? '';
    $newPassword = $_POST['password'] ?? '';

    if (empty($email) || empty($newPassword)) {
        echo "Please provide email and new password";
        exit;
    }

    $hash = password_hash($newPassword, PASSWORD_DEFAULT);

    $stmt = $pdo->prepare("UPDATE users SET password = ? WHERE email = ?");
    if ($stmt->execute([$hash, $email])) {
        echo "Password updated successfully for: $email";
    } else {
        echo "Failed to update password";
    }
    exit;
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>Password Reset</title>
</head>
<body>
    <h1>Reset Admin Password</h1>
    <form method="POST">
        <label>Email:</label>
        <input type="email" name="email" value="admin@shinda.co.ke" required><br>
        <label>New Password:</label>
        <input type="password" name="password" required><br>
        <button type="submit">Reset Password</button>
    </form>
</body>
</html>