-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.php
81 lines (66 loc) · 2.24 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
<?php include 'header.php'; ?>
<?php
require 'database.php';
$message = '';
//check if the username, email and password ahave ben posted
if(!empty($_POST['username']) && !empty($_POST['email']) && !empty($_POST['password'])):
// Enter the new user in the database
$sql = "INSERT INTO users (username, email, password) VALUES (:username, :email, :password)";
$stmt = $conn->prepare($sql);
$stmt->bindValue(':username', $_POST['username']);
$stmt->bindValue(':email', $_POST['email']);
$stmt->bindValue(':password', password_hash($_POST['password'], PASSWORD_BCRYPT));
if( $stmt->execute() ):
$message = 'Successfully created new user';
else:
$message = 'Sorry there must have been an issue creating your account';
endif;
endif;
?>
<!DOCTYPE html>
<html>
<header>
<nav>
<div class="nav-wrapper #ffab40 orange accent-2">
<a href="#" class="brand-logo center">Signup</a>
<a href="index.php"><i class="material-icons"> arrow_back</i></a>
<li><a href="login.php">Login</a></li>
<li><a href="signup.php">Signup</a></li>
</ul>
</div>
</nav>
</header>
<main>
<!--FORM-->
<form action="signup.php" method="POST">
<body>
<div class="container">
<?php if(!empty($message)): ?>
<p><?= $message ?></p>
<?php endif; ?>
</div>
<div class="container">
<div class="input-field col s12">
<input id="username" type="text" class="validate" name="username">
<label for="username">User Name</label>
</div>
<div class="row">
<div class="input-field col s12">
<input id="email" type="email" class="validate" name="email">
<label for="email">Email</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<input id="password" type="password" class="validate" name="password">
<label for="password">Password</label>
</div>
</div>
<button class="waves-effect waves-light btn">Create Account</button>
<p>Have an account?<span><a href="login.php"> Log in</a></span></p>
</div>
</form>
</main>
</body>
</html>
<?php include 'footer.php';?>