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

$email = $_POST['email'];
$new_pass = md5($_POST['new_password']);

$query = "UPDATE tblcred SET pass='$new_pass', otp_code=NULL WHERE LOWER(email)=LOWER('$email')";
$result = mysqli_query($conn, $query);

if ($result) {
    echo json_encode(['success' => true, 'message' => 'Password updated successfully']);
} else {
    echo json_encode(['success' => false, 'message' => 'Password reset failed']);
}
?>
