-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathregistration.php
120 lines (82 loc) · 2.84 KB
/
registration.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
$registered;
include('header.php');
//include("./gamify/gamify.php");
//create class instance with database connection
//$g = new gamify("localhost", "root", "root", "gamify");
//if(isset($_POST['submit']) && ($_POST['submit']=='Regsiter')) {
//}
if(isset($_POST['submit'])=='Regsiter') {
//hold errors
$err = array();
//make sure both passwords match from POST input
//(Doesn't currently work).
if($_POST['username']=='') {
$registered = false;
$err[] = 'You must enter a username.';
}
if($_POST['password1']=='') {
$err[] = 'You must enter a password.';
}
if($_POST['password1'] != $_POST['password2']) {
$err[] = 'The Passwords do not match.';
}
//keep the username to less than '18' characters
//(Doesn't currently work).
if(strlen($username) > 12) {
$err[] = 'Your username is too long.';
}
}
if(!$err) {
//retrieve our data from POST
$username = $_POST['username'];
$password1 = $_POST['password1'];
$password2 = $_POST['password2'];
$email = $_POST['email'];
$password = $password1;
$password = mysql_real_escape_string(stripslashes(md5($_POST['password1'])));
//sanitize username
$username = mysql_real_escape_string($username);
//output pdo errors
$g->debug();
//print_r($_POST);
$register = $g->create_user($username, $password, $email);
$registered = true;
}
?>
<div id="main">
<div class="display_error"><span><?php if(isset($err)) echo $err['0']; ?></span></div>
<div id="content">
<article id="post">
<form name="register" id="registration-form" class="user-form" action="" method="post">
<h2>Registration Form</h2>
<label for="username" class="form-label">Username: </label>
<input type="text" name="username" class="form-field" maxlength="20" />
<label for="password" class="form-label">Password: </label>
<input type="password" class="form-field" name="password1" />
<label for="confirmPassword" class="form-label">Confirm Password: </label>
<input type="password" class="form-field" name="password2" />
<label for="email" class="form-label">Email: </label>
<input type="text" name="email" class="form-field" id="email" />
<input type="submit" name="submit" value="Register" />
</form>
<?php
//}
//echo print_r($_GET);
//echo 'post - ' . print_r($_POST, true);
//echo print_r($_SESSION);
//echo $_GET['thanks'];
if(empty($err) && ($_POST['submit']=='Register')) {
//echo 'Thanks for regsitering';
//echo 'register - ' . print_r($register, true);
//echo print_r($_POST);
?>
<div class="registration-complete">
<h2> Thanks For Registering </h2>
<p> You can now login and contine with your journey. </p>
</div>
<?php } //endif ?>
</article>
</div>
</div>
<?php include('footer.html'); ?>