<?php
require 'db.php';
header('Content-Type: application/json');

$email = $_POST['email'] ?? '';
$code = $_POST['code'] ?? '';

$stmt = $pdo->prepare("SELECT id FROM users WHERE email=? AND reset_code=? AND reset_expires > NOW()");
$stmt->execute([$email, $code]);
$user = $stmt->fetch();

if($user){
    echo json_encode(["status"=>"success"]);
} else {
    echo json_encode(["status"=>"error"]);
}
