-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.php
149 lines (131 loc) · 3.97 KB
/
signup.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
function getUsers() {
$usersFile = 'users.json';
if (!file_exists($usersFile)) {
file_put_contents($usersFile, json_encode([]));
}
return json_decode(file_get_contents($usersFile), true);
}
function saveUsers($users) {
file_put_contents('users.json', json_encode($users, JSON_PRETTY_PRINT));
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$username = $_POST['username'];
$password = password_hash($_POST['password'], PASSWORD_BCRYPT);
$users = getUsers();
foreach ($users as $user) {
if ($user['username'] == $username) {
echo "Username already exists.";
exit();
}
}
$users[] = ['username' => $username, 'password' => $password];
saveUsers($users);
header("Location: login.php");
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Aurora Chat - Signup</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="styles.css">
<style>
.container {
background-image: url('background.png');
background-size: 100% 100%; /* Adjusts the background image to cover the entire div */
background-position: center; /* Centers the background image */
background-repeat: no-repeat; /* Prevents the background image from repeating */
height: 500px; /* Makes the div take up the full viewport height */
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
max-width: 600px;
margin: 20px auto;
color: white;
}
.container a {
color: white;
}
.container input[type=text] {
background-color: #fff;
}
.container input[type=password] {
background-color: #fff;
}
@media screen and (max-width:600px) {
.container {
padding: 10px;
max-width: 100%;
background-image: none;
background-color: transparent;
border:0px solid transparent;
border-style: none;
box-shadow: none;
color: black;
}
.container a {
color: blue;
}
.tabcontent {
background-color: transparent;
}
button[type="submit"], button {
font-family: Poppins, Segoe UI, sans-serif;
padding: 5px 10px;
background-color: #a25fcc;
color: white;
border: none;
cursor: pointer;
border-radius: 4px;
transition: background-color 0.3s ease;
margin: 3px;
font-size: 20px;
}
button[type="submit"]:hover, button:hover {
background-color: #0056b3;
}
a {
font-size: 20px;
}
}
</style>
</head>
<body>
<div class="container">
<noscript>
<style type="text/css">
.ctl2 {
display: none;
}
</style>
<h2>Javascript Error</h2>
<p>It seems like your web browser does not have/support javascript. Please enable it or update your browser to the <b>latest</b> version.</p>
<a href="https://support.google.com/adsense/answer/12654?hl=en">Activate for Chrome</a><br>
<a href="https://support.microsoft.com/en-us/microsoft-edge">Activate for Microsoft Edge</a><br>
<a href="https://support.mozilla.org/en-US/kb/javascript-settings-for-interactive-web-pages">Activate for Firefox</a><br>
<a href="https://support.apple.com/safari">Activate for Safari</a><br>
<a href="">Ok, It's enabled</a><br>
</noscript>
<div class="ctl2">
<h2>Signup</h2>
<p>By signing up you agree to the <a href="terms.php" style="color:blue;">terms of service / privacy policy</a></p>
<form method="post" action="signup.php">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<br>
<br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<br>
<br>
<button type="submit">Signup</button>
<br>
<br>
<a href="login.php"> Login </a>
</form>
</div>
</div>
</body>
</html>