-
Notifications
You must be signed in to change notification settings - Fork 1
/
addTeam.php
81 lines (70 loc) · 2.18 KB
/
addTeam.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
81
<?php $dir = ""; include($dir . "header.php"); ?>
<h1>Registration</h1>
<?php
if($_SESSION['perm']!=100){
header("Location: logout.php");
}
if(isset($_POST['sub'])) {
$servername = "localhost";
$username = "root";
$password = "admin";
$dbname = "cscomp";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO teams (username, password, points, level, problemsRight, problemsWrong, permission, school )";
$sql .= " VALUES('".$_POST['name']."','".$_POST['pass']."','0','".$_POST['level']."','0','0','1','".$_POST['school']."');";
$result = $conn->query($sql);
header("Location: addTeam.php");
}
?>
<table>
<form style = 'margin-top:10em;' action="addTeam" method="post">
<tr><td><label for="name">Name: </label></td>
<td><input type="text" name="name" value=<?php
$servername = "localhost";
$username = "root";
$password = "admin";
$dbname = "cscomp";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$num = 'team'.rand(1, 100);
while (true) {
$num = 'team'.rand(1, 100);
$sql = "SELECT * FROM teams WHERE username = '".$num."';";
$result = $conn->query($sql);
if($result->num_rows==0){
break;
}
}
$conn->close();
echo $num;
?> readonly></td></tr>
<br /><br>
<tr><td><label for="password">Password: </label></td>
<td><input type="password" name="pass" value="" required></td></tr>
<br />
<!-- <label for="level">Level: </label><br> -->
<tr>
<table>
<th>Level</th>
<tr>
<td>Advanced:</td><td><input type="radio" name="level" value="adv"></td><br>
</tr>
<tr>
<td>Novice:</td><td><input type="radio" name="level" value="nov"></td>
</tr>
</table></tr>
<br>
<tr><td><label for="school">School: </label></td>
<td><input type="text" name="school" value="" required></td></tr>
<tr><input type="submit" name="sub" value="Add Team"></tr>
</form>
</table>