-
Notifications
You must be signed in to change notification settings - Fork 1
/
regstration.php
161 lines (126 loc) · 4.01 KB
/
regstration.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<style>form {
font:13px Georgia, "Times New Roman", Times, serif;
background:#eee;
margin:20px;
padding:10px 20px;
width:330px;
}form ol {
list-style:none;
margin:0;
padding:0;
}
form li {
padding:6px;
background:#e1e1e1;
margin-bottom:1px;
}
form li#send {
background:none;
margin-top:6px;
}form label {
/*float:left;
width:150px;
text-align:right;
margin-right:7px;
color:#0066CC;
line-height:23px; /* This will make the labels vertically centered with the inputs */
}
form input,
form textarea {
padding:4px;
font:13px Georgia, "Times New Roman", Times, serif;
border:1px solid #999999;
width:200px;
}
form input:focus,
form textarea:focus {
border:1px solid #666;
background:#e3f1f1;
}</style><?php
include 'core/init.php';
logged_in_redirect();
include 'includes/overall/header.php';
//checking the empty fields
$error = array();
if(empty($_POST)===false){
if(isset($_POST['submit'])){
$required_fields= array('username','password','password_again','firstname','email','branch','year');
foreach($_POST as $key=>$value){
if(empty($value)&&in_array($key,$required_fields)===true){
$error[] = 'Fields Marked with Aiersticks are compulsory';
break;
}
}
}
//if user name exists then show error
if(empty($errors)=== true){
if(user_exists($_POST['username'])===true)
{
$error[] = 'the username \''.$_POST['username'].'\' already exits';
}
//function for checking spaces in user name
if(preg_match('/\\s/',$_POST['username'])){
$error[]='Username must not contain the spaces';
}
if(strlen($_POST['password'])<6){
$error[] = 'your password must be atleasr 6 character long';
}
if($_POST['password']!=$_POST['password_again']){
$error[]='Password does not match';
}
//filtering email addres usin special constant
if(filter_var($_POST['email'],FILTER_VALIDATE_EMAIL)===false){
$error[]='Please Enter a valid email address';
}
if(email_exists($_POST['email'])===true){
$error[] = 'the email \''.$_POST['email'].'\' already in used';
}
}
}
?>
<div align="justify" style="alignment-adjust:hanging"><td><?php
if(isset($_GET['success'])&&empty($_GET['success'])){
echo "<div align='center' id= ><h2>you have registered successfully</h2></div>";}else{
if(empty($_POST)=== false && empty($error)=== true){
$register_data = array('username' =>$_POST['username'],
'password' =>$_POST['password'],
'firstname' =>$_POST['firstname'],
'lastname' =>$_POST['lastname'],
'email' =>$_POST['email'],
'branch' =>strtolower($_POST['branch']),
'year' =>$_POST['year'],
'emailcode' => sha1($_POST['username'] + date()));
register_data($register_data);
header('location:regstration.php?success');
exit();
}
else if(empty($error)===false) {
echo output_errors($error);}
?>
<h2 style="text-decoration:underline; background-position:top; position:relative; ">Registration Form</h2><form action="" method="post">
<ul >
<li>
Username*:<br><input type="text" name="username" autocomplete="on"></li><li>
Password*:<br><input type="password" name="password" autocomplete="on"><br></li><li>
Password again*:<br><input type="password" name="password_again" autocomplete="on"><br></li><li>
First Name*:<br><input type="text" name="firstname" autocomplete="on"><br></li><li>
Last Name*:<br><input type="text" name="lastname" autocomplete="on"><br></li><li>
Email Id*:<br><input type="text" name="email" autocomplete="on"><br></li><li>
Branch*:<br><input type="text" name="branch" autocomplete="on" ><br></li><li>
year:<br><select name="year">
<option value="1">First</option>
<option value="2">Second</option>
<option value="3">Third</option>
<option value="4">Fourth</option>
</select>
</li></ul>
<input type="submit" value="Register" name="submit">
</form>
</td>
</div>
<?php
}
include 'includes/aside.php';
?>
<?php include 'includes/overall/footer.php';
?>