<?php
header('Content-Type: text/html; charset=utf-8');

show_source(__FILE__); // <- IMPORTANT REMOVE THIS LINE/CODE or everybody can see your code!!!

include ('DBcon.php');
// in DBcon.php:
// $db_hostname = "**************";
// $db_database = "**************";
// $db_username = "**************";
// $db_password = "**************";

$_POST = json_decode(file_get_contents('php://input'), true);

    $mysqli = new mysqli($db_hostname, $db_username, $db_password, $db_database);
        
    if (mysqli_connect_errno())
    {
        echo 'error';
        exit();
    }

// Use update or delete in sql

    // $stmt = $mysqli->prepare("DELETE FROM gamers
    // WHERE gamerID = ?");
    // $stmt->bind_param("s", $_POST['gamerID']);
    // $stmt->execute();

    $status = 'deleted';
    $stmt = $mysqli->prepare("UPDATE gamers SET status = ?
    WHERE gamerID = ?");
    $stmt->bind_param("ss", $status, $_POST['gamerID']);
    $stmt->execute();

    // Check if rows were affected
    if ($stmt->affected_rows > 0) {
      echo "deletedOK";
    } else {
      echo "error";
    }

    $stmt->close();
?>
error