-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.php
59 lines (57 loc) · 1.52 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
<?php
session_start();
require "./config/setup.php";
require "./config/email.php";
require "./classes/validator.class.php";
require "./classes/userview.class.php";
require "./classes/userctrl.class.php";
require "./classes/mail.class.php";
?>
<!DOCTYPE html>
<html>
<head>
<title>Signup</title>
<link rel="stylesheet" href="./css/user_input.css">
</head>
<body>
<div class="userform">
<h2>Logo</h2>
<h3>Signup</h3>
<form method="post">
<input type="text" name="login" placeholder="Username">
<input type="text" name="email" placeholder="Email">
<input type="password" name="passwd" placeholder="Password">
<p>*Minimum of 6 characters. Should include at least one capital letter and one digit!</p>
<input type="password" name="passwd2" placeholder="Re-enter password">
<button type="submit">Signup</button>
</form>
<a href="login.php">Login</a>
</div>
</body>
</html>
<?php
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
$NewUser = new validator($_POST);
$DbUser = new UserView($DB_DSN, $DB_USER, $DB_PASSWORD);
$result = $DbUser->get_user($NewUser->username, $NewUser->email);
$NewUser->validate($result);
if ($NewUser->error)
{
echo json_encode($NewUser->error);
exit;
}
$CreateUser = new UserCtrl($DB_DSN, $DB_USER, $DB_PASSWORD);
$CreateUser->create_user($NewUser);
$confirm = new SendMail($EM_HOST, $EM_PORT, $EM_USER, $EM_PASSWD);
$confirm->confirmation($NewUser);
if ($confirm->error == true)
{
exit;
}
else
{
header("Location: login.php");
}
}
?>