-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate.php
105 lines (89 loc) · 3.14 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
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
<?php
include 'main.php';
include 'adduser.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style/main.css">
<link rel="icon" href="style/icon.png">
<title>Create account</title>
<script src="functions.js"></script>
</head>
<!--PAGE CONTENT-->
<body>
<!--NAVIGATION BAR-->
<nav>
<img src="style/logo.png" style="padding:20px;" alt="Logo">
<ul>
<?php
echo $nav_menu;
?>
</ul>
</nav>
<p>
<?php
echo $new_status;
?>
</p>
<div id="pagecontent">
<form method="POST" id="formdata" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<div class="container">
<h1>Register</h1>
<p>Please fill in this form to create an account.</p>
<hr>
<table>
<tr>
<td><label for="reg_name"><b>Name</b></label></td>
<td><input type="text" placeholder="Enter username" name="reg_name" id="reg_name" required></td>
</tr>
<tr>
<td><label for="psw"><b>Password</b></label></td>
<td><input type="password" placeholder="Enter Password" name="psw" id="psw" required></td>
</tr>
<tr>
<td><label for="psw-repeat"><b>Repeat Password</b></label></td>
<td><input type="password" placeholder="Repeat Password" name="psw-repeat" id="psw-repeat" required></td>
</tr>
<tr>
<td></td>
<td>
<button type="submit" id="registerbtn" class="button" style="font-size: 1rem;">Register</button>
</td>
</tr>
</table>
<p>By creating an account you agree to our <a href="#">Terms & Privacy</a>.</p>
</div>
<div class="container signin" style="padding-bottom:200px;">
<p>Already have an account? <a class="button" style="font-size: 1rem; background-color: #276678; color:white;" href="login.php">Sign in</a>.</p>
</div>
</form>
</div>
<?php
if ($_POST) {
$username = trim($_POST['username']);
$password = trim($_POST['password']);
if (!strlen($username) || !strlen($password)) {
die('Please enter a username and password');
}
$handle = fopen("accounts.csv", "r");
while (($data = fgetcsv($handle)) !== FALSE) {
if ($data[0] == $username && $data[1] == $password) {
$_SESSION["username"] = $username;
$_SESSION["password"] = $password;
header("Location: index.php");
break;
}
}
fclose($handle);
// header("Location: index.php");
}
?>
<!--PAGE FOOTER-->
<?php
echo $page_footer;
?>
</body>
</html>