<?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();
    }

    $mysqli->set_charset("utf8mb4");

    $stmt = $mysqli->prepare("SELECT g.name as name, g.status as status, g.birthdate as birthdate, g.regdate as regdate
    FROM gamers g  
    WHERE g.gamerID = ?");
    $stmt->bind_param("s", $_POST['gamerID']);
    $stmt->execute();
    $stmt->store_result();
    if($stmt->num_rows === 0) exit('error');
    $stmt->bind_result($name, $status, $birthdate, $regdate);
    $stmt->fetch();
    $stmt->close();

    $gamer[] = array(
        'name'      => $name,
        'status'    => $status,
        'birthdate' => $birthdate,
        'regdate'   => $regdate
       );

    echo json_encode($gamer);
?>
error