-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidateUser.php
131 lines (102 loc) · 2.81 KB
/
validateUser.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE html>
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
include 'db_connection.php';
$con = OpenCon();
$user = $_GET['username'];
$pass = $_GET['password1'];
$pass1 = $_GET['password2'];
$sql = "SELECT COUNT(name) FROM people WHERE name = '$user';";
$rs = mysqli_query($con, $sql);
$count = mysqli_fetch_row($rs);
$count = $count[0];
if ($count == 0){
// If the two passwords are equal, then create a new user
if ($pass1 === $pass){
$sql = "INSERT INTO `people`(`name`, `password`, `voted`) VALUES ('$user', '$pass', 0)";
$con->query($sql);
?>
<html>
<head>
<title>Eurovision scorer</title>
<link rel="stylesheet" href="styles/style.css">
</head>
<body>
<header>
<h1>Log in</h1>
</header>
<main style = "text-align: center;">
<p>User created!</p>
<form action="index.html">
<input type="submit" value="Login in" />
</form>
</main>
</body>
</html>
<?php
}
else{
?>
<!DOCTYPE html>
<html>
<head>
<title>Eurovision scorer</title>
<link rel="stylesheet" href="styles/style.css">
</head>
<body>
<header>
<h1>Log in</h1>
</header>
<main style = "text-align: center;">
<form name = "newUser" action="validateUser.html" method="get" accept-charset="utf-8">
<label for = "username">Username </label>
<input type = "username" name="username" placeholder="USERNAME" required>
<br><br>
<label for = "password1">Password </label>
<input type = "password" name="password1" placeholder="PASSWORD" required>
<br><br>
<label for = "password2">Password </label>
<input type = "password" name="password2" placeholder="PASSWORD" required>
<br><br>
<input type = "submit" value="Create" style = "color: #111;">
<p>Password did not match!</p>
</form>
</main>
</body>
</html>
<?php
}
}
else{
?>
<!DOCTYPE html>
<html>
<head>
<title>Eurovision scorer</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>Log in</h1>
</header>
<main style = "text-align: center;">
<form name = "newUser" action="validateUser.html" method="get" accept-charset="utf-8">
<label for = "username">Username </label>
<input type = "username" name="username" placeholder="USERNAME" required>
<br><br>
<label for = "password1">Password </label>
<input type = "password" name="password1" placeholder="PASSWORD" required>
<br><br>
<label for = "password2">Password </label>
<input type = "password" name="password2" placeholder="PASSWORD" required>
<br><br>
<input type = "submit" value="Create" style = "color: #111;">
<p>User name in use!</p>
</form>
</main>
</body>
</html>
<?php
}
?>