forked from vineetjc/hackaholic-2018
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prelims.php
39 lines (29 loc) · 896 Bytes
/
prelims.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
35
36
37
38
39
<?php
$host="localhost";
$username="hackaholic"; // Mysql username
$password="vineetissucky"; // Mysql password
$db_name="hackaholic";
$user_id = $_POST["user_id"];
$p1 = $_POST["player_1"];
$p2 = $_POST["player_2"];
$college = $_POST["college"];
$score = 0;
$link = mysql_connect($host, $username, $password)or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$obj = new stdClass();
if ($link) {
$obj->connection_status = "success";
} else {
$obj->connection_status = "failure";
}
$sql = "INSERT INTO prelims (user_id, player_1, player_2, college, score) VALUES ('".$user_id."','".$p1."','".$p2."','".$college."',".$score.")";
$result = mysql_query($sql);
if ($result) {
$result = "reg_success";
session_start();
$_SESSION['user_id'] = $user_id;
}else {
$result = "reg_failed";
}
echo json_encode($result);
?>