The following files exists in this folder. Click to view.
stop_match.php43 lines UTF-8 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['challengerId'] == (int)$a['playerId'] && $match['status'] == 'request'){
$exit = FALSE;
validateladdertime($match['defenderId'], 'yes');
}
}
if ($exit == TRUE){
header('location: home.php');
exit();
}
//Sätter statusen till 'stopped'
$sql = "UPDATE Matches SET status = :status WHERE matchId = :matchId;";
$stm = $pdo->prepare($sql);
$stm->execute([
':status' => 'stopped',
':matchId' => $match['matchId']]);
if(isset($_GET['openladder'])){
header('location: home.php?openladder='.$_GET['openladder'].'');
exit();
}
header('location: home.php?');
exit();
?>