-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_answer.php
34 lines (34 loc) · 1.31 KB
/
check_answer.php
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
<?php
session_start();
$servername = "localhost";
$username = "maveli";
$password = "maveli";
$dbname = "ONAMHUNT";
$flag = 0;
$conn = new mysqli($servername, $username, $password, $dbname);
if (!$conn) {
echo "failed";
}
$answers = array("problem1" => "thrissur", "problem2" => "saroja", "problem3" => "kelu", "problem4" => "പരമപീഠസ്ഥാനീയ ബലിസത്മ വാതായനം തുറക്കട്ടെ", "problem5" => "kavaadam", "problem6" => "3.14159265359", "problem7" => "vishwapriyanatha maha bali");
if($_GET["answer"] == $answers[$_GET["task"]]){
$team_name = $_SESSION["team_name"];
$team_code = $_SESSION["team_code"];
$sql = 'SELECT * FROM scoreboard WHERE team_code = "' . $team_code . '" AND ' . $_GET["task"] . ' IS NULL';
$result = mysqli_query($conn, $sql);
if(mysqli_num_rows($result) > 0){
$flag = 1;
mysqli_close($conn);
$conn = new mysqli($servername, $username, $password, $dbname);
}
if($flag == 1){
$sql = "UPDATE scoreboard SET " . $_GET["task"] . " = SYSDATE() WHERE team_code = '" . $team_code . "'";
$result = mysqli_query($conn, $sql);
header("Location: scores.php");
}else{
header("Location: scores.php");
}
}else{
header("Location: scores.php");
}
mysqli_close($conn);
?>