-
Notifications
You must be signed in to change notification settings - Fork 0
/
sign.php
179 lines (125 loc) · 4.35 KB
/
sign.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php
session_start();
?>
<?php
if(isset($_POST['submit'])){
include 'data.php';
function test($data){
$data=stripslashes($data);
$data=htmlspecialchars($data);
return $data;
}
$name=$username=$email=$mobile=$password=$validpassword="";
$nameErr=$usernameErr=$emailErr=$mobileErr=$validpasswordErr="";
$total=0;
if($_SERVER["REQUEST_METHOD"]=="POST"){
$name = test($_POST["name"]);
$username= test($_POST["user"]);
$email= test($_POST["email"]);
$mobile= test($_POST["mobile"]);
$password= test($_POST["password"]);
$validpassword= test($_POST["validpassword"]);
}
if(!preg_match('/^[a-zA-Z ]*$/' , $name)){
$nameErr="valid name required";
}
else $total++;
if(!preg_match('/^[a-zA-Z0-9]+([a-zA-Z0-9](_|-| )[a-zA-Z0-9])*[a-zA-Z0-9]+$/' , $username)){
$usernameErr="valid username required";
}
else $total++;
if(!preg_match('/(\+91[\-\s]?)?[0]?(91)?[789]\d{9}/' , $mobile)){
$mobileErr="valid mobile number required";
}
else $total++;
if(!preg_match('/^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/' , $email)){
$emailErr="valid email required";
}
else $total++;
if($password!=$validpassword){
$validpasswordErr="password does not match";
}
else $total++;
if($total==5){
$_SESSION["username"]=$username;
$_SESSION["name"]=$name;
$_SESSION["email"]=$email;
$_SESSION["mobile"]=$mobile;
echo $_SESSION["username"];
header("Location: index.php");
data($name, $username, $email, $mobile, md5($password));
}
else{
echo "enter valid credentials";
}
}
?>
<html>
<head>
<title>Sign Up</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="sign.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
$(document).ready(function () {
$("#username").blur(function () {
var username = $(this).val();
if (username == '') {
$("#availability").html("");
}else{
$.ajax({
url: "validation.php?uname="+username
}).done(function( data ) {
$("#availability").html(data);
});
}
});
});
</script>
</head>
<body>
<div class="main">
<h1>Sign Up</h1>
<form method="post" action="sign.php">
<ul>
<div class="div1">
<li><input type="email" id="email" name="email" class="input" placeholder="Enter email" onchange="emailval()" required></li>
<span class="error"><?php if(isset($email)) {echo $emailErr;}?></span>
<li><input type="text" id="name" name="name" class="input" placeholder="Enter name" onchange="nameval()" required></li>
<span class="error"><?php if(isset($name)) {echo $nameErr;}?></span>
<li><input type="text" id="username" name="user" class="input" placeholder="Enter username" onchange="userval()" required></li>
<span class="error"><?php if(isset($username)){echo $usernameErr;}?></span>
<div id="availability"></div>
<li><input type="text" id="mobile" name="mobile" class="input" placeholder="Enter mobile num" onchange="mobiles()" required="required"></li>
<span class="error"><?php if(isset($mobile)){echo $mobileErr;}?></span>
<li><input type="password" id="pass" name="password" class="input" placeholder="Enter password" required></li>
<li><input type="password" id="valpass" name="validpassword" class="input" placeholder="Confirm password" required onchange="validpass()"></li>
<span class="error"><?php if(isset($validpassword)){echo $validpasswordErr;}?></span>
<li>
<select class="select" required>
<option class="option" selected="selected" disabled>Gender</option>
<option class="option">Male</option>
<option class="option">Female</option>
</select><br>
<select class="select" required>
<option class="option" selected="selected" disabled>Education</option>
<option class="option">Primary</option>
<option class="option">Secondary</option>
<option class="option">Sr. Secondary</option>
<option class="option">Graduate</option>
<option class="option">Post Graduate</option>
<option class="option">Others</option>
</select>
</li>
</div>
<li>
<input type="checkbox" name="check" id="term" required>
<label for="term">I agree to the terms and conditions!!</label>
</li>
</ul>
<input type="reset" name="reset" value="Reset!" class="button">
<input type="submit" name="submit" value="Submit!" class="button">
</form>
</div>
</body>
</html>