-
Notifications
You must be signed in to change notification settings - Fork 1
/
adminSubmit.php
80 lines (75 loc) · 2.85 KB
/
adminSubmit.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
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
<?php include "global.php"; ?>
</head>
<body>
<?php
include 'nav.php';
include 'php/dbDataConn.php';
$id = $_GET["id"];
$action = $_GET["action"];
if ($action == 0) { //Delete
$sql = "DELETE FROM " . $GLOBALS['DB']['TABLE']['USER'] . " WHERE id = $id";
if ($dbDataConn->query($sql) === TRUE) {
$last_id = mysqli_insert_id($dbDataConn);
echo "
<div class='container'>
<a href='$databasePath'><button type='button' class='btn btn-success btn-xl' style='width:100%; height:200px;'><h1 style='font-size: 500%;'>Click Here</h1></button></a>
</div>
";
echo "<h1> ID: <strong>$id</strong> was removed successfully.</h1>";
} else {
echo "Error: " . $sql . "<br>" . $dbDataConn->error . "
<div class='container'>
<a href='admin' target='_blank'><h1>An error occured!</h1></a>
</div>
";
}
}
else { //Toggle admin
$result = mysqli_query($dbDataConn, "SELECT * FROM " . $GLOBALS['DB']['TABLE']['USER'] . " WHERE id = $id LIMIT 1");
while ($row = mysqli_fetch_array($result)) {
$isAdmin = $row['isAdmin'];
}
echo '
<div class="container">
<h2>Editing ID: ' . $id . ' (Scout: ' . $username . ')</h2>';
echo '
<div class="container">
<form class="form-horizontal" action="saveEdit.php" method="post">
<input type="hidden" name="id" value="' . $id . '">
<div class="form-group">
<label class="control-label col-sm-2" for="teamNum">Team Number:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="teamNum" value="' . $teamNum . '" name="teamNum">
</div>
</div>
<div class="text-center">
<a id="switch"><button type="button" class="btn btn-danger"><i class="fa fa-arrows-v" aria-hidden="true"></i></button></a>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="matchNum">Match Number:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="matchNum" value="' . $matchNum . '" name="matchNum">
</div>
</div>
<div class="form-group">
<div id="submitBox" style="margin-left:auto; margin-right:auto; display:block;"><button type="submit" class="btn btn-danger btn-lg" style="width:100%">Submit</button></div>
</div>
</form>
</div>
';
echo '</div>';
}
$dbDataConn->close();
?>
<script>
var switchButton = document.getElementById('switch');
switchButton.onclick = switchText;
function switchText() {
var teamNum = document.getElementById('teamNum').value;
var matchNum = document.getElementById('matchNum').value;
document.getElementById('teamNum').value = matchNum;
document.getElementById('matchNum').value = teamNum;
}
</script>
</body>
</html>