-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.php
executable file
·99 lines (81 loc) · 3.14 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
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
$page_title = "Signup";
include_once 'header.php';
//Get database connection
include_once 'includes/database.php';
//include_once 'includes/login_database.php';
$database = new Database();
$db = $database->getConnection();
// if the form was submitted
if ($_POST) {
if ($_POST['password'] == $_POST['password2']) {
// instantiate product object
include_once 'objects/Users.php';
$users = new Users($db);
// set product property values
$users->username = $_POST['username'];
$users->password = $_POST['password'];
$users->user_type = $_POST['adminpassword'];
$users->user_email = $_POST['email'];
// create the product
if ($users->create()) {
echo "<div class=\"alert alert-success alert-dismissable\">";
echo "<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">×</button>";
echo "User was created.";
echo "<div class='right-button-margin'>";
echo "<a href='login.php' class='btn btn-default pull-right'>Login</a>";
echo "</div>";
echo "</div>";
}
// if unable to create the product, tell the user
else {
echo "<div class=\"alert alert-danger alert-dismissable\">";
echo "<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">×</button>";
echo "Unable to create user.";
echo "</div>";
}
} else {
echo "<div class=\"alert alert-danger alert-dismissable\">";
echo "<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">×</button>";
echo "Passwords need to match.";
echo "</div>";
}
}
?>
<form action='signup.php' method='post'>
<table class='table table-hover table-responsive table-bordered'>
<tr>
<td><input type='text' name='username' placeholder="User Name" class='form-control' required></td>
</tr>
<tr>
<td><input type='password' name='password' placeholder="Password" class='form-control' required></td>
</tr>
<tr>
<td><input type="password" name="password2" placeholder="Password Confirmation" class="form-control" required</td>
</tr>
<tr>
<td><input type='email' name='email' placeholder="Email" class='form-control' ></td>
</tr>
<tr class="adminpass">
<td><input type='password' name='adminpassword' placeholder="Administrator Password" class='form-control' ></td>
</tr>
<tr class="aphelp">
<td>
<h5><weak>If you do not have a password leave field blank</weak></h5>
</td>
</tr>
<tr>
<td>
<button type="submit" align="right" class="btn btn-primary btn-block">Login</button>
</td>
</tr>
</table>
</form>
<?php
include_once 'footer.php';
?>