header(); if($loggedIn == true) { if($_POST['submit'] ?? "No" == "Create place" && isset($_FILES['userfile']['name']) && isset($_POST['name']) || isset($_POST['description']) && isset($_POST['playerlimit']) && $_POST['playerlimit'] >= 1 ) { if($user->getMoney('false') >= $placeprice) { $q = $con->prepare("UPDATE users SET money=money-:price WHERE id=:id"); $q->bindParam(':id',$_SESSION['user'],PDO::PARAM_INT); $q->bindParam(':price',$placeprice,PDO::PARAM_INT); $q->execute(); $q = $con->prepare("INSERT INTO games (name, description, creator, players, state) VALUES (:name, :description, :creator, :playerlimit, 'pending')"); $q->bindParam(':name',$_POST['name']); $q->bindParam(':description',$_POST['description']); $q->bindParam(':playerlimit',$_POST['playerlimit']); $q->bindParam(':creator',$_SESSION['user'],PDO::PARAM_INT); $q->execute(); header("Location: /games?uploaded=true"); exit; } } } ?>