In lobby.php
<script>
function join_game(roomid){
$.ajax({
method: "post",
dataType: "json",
url: "join.php",
data: {room_id: roomid}
});
}
<script>
In join.php
<?php
session_start();
include("connect.php");
global $conn;
$username = $_SESSION['login_user'];
$id = $_POST["room_id"];
$sql = "UPDATE check_exist
SET player_join = '$username' , game_exist_lobby = '0'
WHERE ceid = '$id'";
mysqli_query($conn, $sql);
header("location: game.php?last_id=" . $id);
mysqli_close($conn);
I don't understand why the header didn't work and remain at the page, but the SQL statements is working towards the database and updates the data, and I don't know how to debug, similar code is working in other php, can anyone tell me any possible error to make this problem and any way to debug? Thanks