<?php
	require_once('session.php');

    $users = $u['user'];
    $titles = str_replace(array( "’","'" ),"&apos;",$_POST['title']);
    $title = strtoupper($titles);
    $price = $_POST['price'];
    $satuan = $_POST['satuan'];
    $diskon = $_POST['diskon'];
    $minBet = $_POST['min_bet'];
    $maxBet = $_POST['max_bet'];
    $parents = $_POST['parent'];
    $postID = $_POST['postID'];
    $date = date('Y-m-d');
    $kode = date('YdmHis');
    if($postID == ''){
        $query = mysqli_query($conn,"INSERT INTO `tb_game` (`title`, `price`, `diskon`, `min_bet`, `max_bet`, `satuan`, `parent`, `status`) VALUES ('$title', '$price', '$diskon', '$minBet', '$maxBet', '$satuan', '$parents', 0)") or die(mysqli_error($conn));
        header('location:../game/?notif=1');
    }
    else {
        $query = mysqli_query($conn,"UPDATE `tb_game` SET `title` = '$title', `price` = '$price', `diskon` = '$diskon', `min_bet` = '$minBet', `max_bet` = '$maxBet', `satuan` = '$satuan', `parent` = '$parents' WHERE cuid = '$postID'") or die(mysqli_error($conn));
        header('location:../game/?postID='.$postID.'&notif=1');
    }
?>