<?php
session_start();
include_once('../../config/#Config.php');
if(!$_SESSION['UserName']){
die('<script>window.location.href=\''.$config['site']['url'].'index.php\';</script>');
} else {
$get_AD = mysqli_query($conn, "Select * From config_admin WHERE Account = '".$_SESSION['UserName']."'");
if(!mysqli_num_rows($get_AD)){
	die('Không đủ quyền.');
}	
    /* ------------------------------------------- CONNECT CHAR SV ------------------------------- */
    $get_Server = mysqli_query($conn, "Select * From config_server WHERE ServerID = '" . $_POST['sv'] . "'");
    if (!mysqli_num_rows($get_Server)) {
        die('Lấy thông tin Máy chủ thất bại.');
    }
    $get_Server = mysqli_fetch_array($get_Server, MYSQLI_ASSOC);
    $conn_char  = @mysqli_connect($get_Server['IPdata'], $get_Server['Userdata'], $get_Server['PassData'], $get_Server['Databases']);
    if ($conn_char->mysqli_connect_errno) {
        die("Connection failed: " . $conn_char->mysqli_connect_errno);
    }
	mysqli_query($conn_char, "SET NAMES 'utf8'"); 
    /* ------------------------------------------- CONNECT CHAR SV ------------------------------- */	
        $get_nhannvat = mysqli_query($conn_char, "Select * From Player WHERE Account = '" . $_POST['user'] . "'");
    if (mysqli_num_rows($get_nhannvat)) {
        echo '<option value="0">-- Chọn Nhân Vật --</option>';
		while($row = mysqli_fetch_array($get_nhannvat)){
		echo '<option value="'.$row['ID'].'">'.$row['ID'].' - '.$row['PlayerName'].'</option>';
		}
	}
}

?>