-
Notifications
You must be signed in to change notification settings - Fork 3
/
create.php
56 lines (55 loc) · 1.71 KB
/
create.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
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Create an Account | PreBook</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<link rel="shortcut icon" type="image/png" href="img/logo.png">
</head>
<body>
<nav>
<div class="logo">
<img src="img/logo.png"> <h1> PreBook</h1><span><i>Cheap, Reliable, Instant</i></span>
</div>
</nav>
<main>
<div class="bar">
<?php
require('db.php');
$query = "SELECT * FROM login";
$record = mysqli_query($db_conn, $query) or die("Query Error!".mysqli_error($db_conn));
$username = $_POST['desiredusername'];
$password = $_POST['desiredpassword'];
$flag = 0;
while ($row = mysqli_fetch_array($record)) {
if ($row['UserId'] == $username) {
$flag = 1;
?>
<h2>Oops...</h2>
<span class="aside"><i>account already exists, use another username.</i></span>
</div>
<i class="fas fa-exclamation-triangle full-icon"></i>
<?php
header( "refresh:3;url=createaccount.html" );
}
}
if ($flag == 0) {
$query = "INSERT INTO login VALUES ('$username', '$password')";
if (!mysqli_query($db_conn, $query)) {
echo "<p>Error insert!!<br>".mysqli_error($db_conn)."</p>";
}
?>
<h2>Yaaay!</h2>
<span class="aside"><i>you've registered. You'll be redirected to login, where you can use these details.</i></span>
</div>
<i class="fas fa-check-square full-icon"></i>
<?php
header( "refresh:3;url=index.html" );
}
mysqli_free_result($record);
mysqli_close($db_conn);
?>
</main>
</body>
</html>