setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); $dbcon->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); }catch (PDOExpection $e){ exit; } $stmt = $dbcon->prepare("SELECT username FROM users WHERE id=:id;"); $stmt->bindParam(':id', $userId, PDO::PARAM_INT); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); if ($stmt->rowCount() == 0) { echo 'no'; }else{ if ($result['username'] != $username) { echo 'no'; }else{ $stmt = $dbcon->prepare("SELECT * FROM gameJoins WHERE uid=:id;"); $stmt->bindParam(':id', $userId, PDO::PARAM_INT); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); if ($stmt->rowCount() == 0) { echo 'no'; }else{ $currentTime = date('Y-m-d H:i:s'); $to_time = strtotime($currentTime); $from_time = strtotime($result['time']); $timeSince = round(abs($to_time - $from_time) / 60,2); if ($timeSince > 5) { echo 'no'; }else{ if ($result['gameId'] != $gameId) { echo 'no'; }else{ echo 'yes'; } } } } } $dbcon = null; ?>