<?php
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    echo "Access Denied";
    exit();
}

include 'config.php';

foreach(array('Name', 'Mobile_Number', 'Winning', 'Balance', 'Email', 'Password', 'Request', 'Status', 'Fack_Request', 'Auth') as $field) {
    if(!isset($_POST[$field]) || trim($_POST[$field]) == '') {
        echo $field." is required";
        exit();
    }
}

$sql = "UPDATE users SET Name = ?, Mobile_Number = ?, Winning = ?, Balance = ?, Email = ?, Password = ?, Request = ?, Status = ?, Fack_Request = ? WHERE Auth = ?";

$stmt = $conn->prepare($sql);
if ($stmt) {
    $stmt->bind_param("ssssssssss", $_POST['Name'], $_POST['Mobile_Number'], $_POST['Winning'], $_POST['Balance'], $_POST['Email'], $_POST['Password'], $_POST['Request'], $_POST['Status'], $_POST['Fack_Request'], $_POST['Auth']);

    if ($stmt->execute()) {
        echo "Updated";
    } else {
        echo "Update Failed";
    }
    $stmt->close();
} else {
    echo "Update Failed";
}
$conn->close();
?>