The following files exists in this folder. Click to view.
answer_match.php54 lines ASCII Unix (LF)
<?php
session_start();
require_once('databaseconnection.php');
include('functions.php');
include('check_login.php');
$sql = "SELECT * FROM Matches WHERE matchId = :matchId;";
$stm = $pdo->prepare($sql);
$stm->execute(array('matchId' => $_GET['matchId']));
$match = $stm->fetch(PDO::FETCH_ASSOC);
//Validating player
$sql = "SELECT playerId FROM Players WHERE userId = :userId;";
$stm = $pdo->prepare($sql);
$stm->execute(array('userId' => $_SESSION['userId']));
$res = $stm->fetchAll(PDO::FETCH_ASSOC);
$exit = TRUE;
foreach($res as $a){
if ((int)$match['defenderId'] == (int)$a['playerId']){
if ($match['defenderpoints'] <= playerpoints($match['defenderId'])){
$exit = FALSE;
validateladdertime($match['defenderId'], 'yes'); //Validating the time of the ladder
}
}
}
if ($exit == TRUE){
header('location: home.php');
exit();
}
if (isset($match['matchdate'])){
$matchdate = $match['matchdate'];
}
else{
$matchdate = date('Y-m-d H:i:s');
}
//Uppdating database
$sql = "UPDATE Matches SET responsedate = :responsedate, status = :status, matchdate = :matchdate WHERE matchId = :matchId;";
$stm = $pdo->prepare($sql);
$stm->execute([
':responsedate' => date('Y-m-d H:i:s'),
':status' => $_POST['answer'],
':matchdate' => $matchdate,
':matchId' => $match['matchId']]);
if(isset($_GET['openladder'])){
header('location: home.php?openladder='.$_GET['openladder'].'');
exit();
}
header('location: home.php?');
exit();
?>