-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmatch_users.php
More file actions
81 lines (62 loc) · 2.75 KB
/
Copy pathmatch_users.php
File metadata and controls
81 lines (62 loc) · 2.75 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
//CORS Headers
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: *");
//HTTP inputs
$rest_json = file_get_contents("php://input");
$_POST = json_decode($rest_json, true);
//connecting to SQL Database
$con = mysqli_connect("localhost", "root", "", "othscmsdb");
$rows = [];
$name = $_POST['name'];
$team = $_POST['team'];
if($team != ''){
//looking for matching username
$sql = "SELECT * FROM teams where team = \"$team\"";
$res = mysqli_query($con, $sql);
if(mysqli_num_rows($res)>0){
while($row = mysqli_fetch_assoc($res)){
$info = array("member" => 1, "name" => $row['member1'], "team" => $row['team'], "teamid" => $row['id'], "score" => $row['score1'], "school" => $row['school'],);
array_push($rows, $info);
$info = array("member" => 2, "name" => $row['member2'], "team" => $row['team'], "teamid" => $row['id'], "score" => $row['score2'], "school" => $row['school'],);
array_push($rows, $info);
$info = array("member" => 3, "name" => $row['member3'], "team" => $row['team'], "teamid" => $row['id'], "score" => $row['score3'], "school" => $row['school'],);
array_push($rows, $info);
}
}
echo json_encode($rows);
die;
}
if($name == '')die;
//looking for matching username
$sql = "SELECT * FROM teams where member1 = \"$name\"";
$res = mysqli_query($con, $sql);
//checking if password is correct
if(mysqli_num_rows($res)>0){
while($row = mysqli_fetch_assoc($res)){
$info = array("member" => 1, "name" => $row['member1'], "team" => $row['team'], "teamid" => $row['id'], "score" => $row['score1'], "school" => $row['school'],);
array_push($rows, $info);
}
}
//looking for matching username
$sql = "SELECT * FROM teams where member2 = \"$name\"";
$res = mysqli_query($con, $sql);
//checking if password is correct
if(mysqli_num_rows($res)>0){
while($row = mysqli_fetch_assoc($res)){
$info = array("member" => 2, "name" => $row['member2'], "team" => $row['team'], "teamid" => $row['id'], "score" => $row['score2'], "school" => $row['school'],);
array_push($rows, $info);
}
}
//looking for matching username
$sql = "SELECT * FROM teams where member3 = \"$name\"";
$res = mysqli_query($con, $sql);
//checking if password is correct
if(mysqli_num_rows($res)>0){
while($row = mysqli_fetch_assoc($res)){
$info = array("member" => 3, "name" => $row['member3'], "team" => $row['team'], "teamid" => $row['id'], "score" => $row['score3'], "school" => $row['school'],);
array_push($rows, $info);
}
}
echo json_encode($rows);
?>