-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer2.php
More file actions
52 lines (43 loc) · 1.56 KB
/
timer2.php
File metadata and controls
52 lines (43 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
if (empty($_GET['code'])) {
header('Location:error.php'); }
function getUser($bcode){
$db = require __DIR__ . '/db_conn.php';
$query = 'SELECT handle, difficulty FROM scores WHERE barcode = :bar';
$select = $db->prepare($query);
$barcodeIn = ['bar' => $bcode];
$select->execute($barcodeIn);
return $select->fetch(PDO::FETCH_ASSOC);
//var_dump($row); // Uncomment for Debugging
}
function setStart($bcode){
$db = require __DIR__ . '/db_conn.php';
$loadTime = time();
$query = "UPDATE scores SET startTime = '$loadTime' WHERE barcode= :bar";
$select = $db->prepare($query);
$barcodeIn = ['bar' => $bcode];
$select->execute($barcodeIn);
return $loadTime;
}
function startGame($bcode){
$db = require __DIR__ . '/db_conn.php';
$loadTime = time();
$query = "UPDATE scores SET inprogress = '1' WHERE barcode= :bar";
$select = $db->prepare($query);
$barcodeIn = ['bar' => $bcode];
$select->execute($barcodeIn);
}
$user = getUser($_GET['code']);
setStart($_GET['code']);
startGame($_GET['code']);
if ($user === false) {header('Location:error.php'); }
echo "<div style='text-align:center'>";
echo "<font size='25'><h1> Contestant Information:</h1></font>";
echo "<font size='15'> <h3> Name / Handle: ", $user['handle'] , "<br>";
echo "Difficulty Level: " , $user['difficulty'] , "</h3></font>";
echo "<h4> Timestamp Recorded as: ", setStart($_GET['code']), "</h4></div>";
echo "<font size='25'><h1>";
require __DIR__ . '/counter.php';
echo "</h1></font>";
echo "<iframe frameborder='0' src='checkEnd.php?code=" . $_GET['code'] . "'></iframe>";
?>