-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.php
199 lines (162 loc) · 5.22 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
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Form</title>
<link rel="stylesheet" href="./signup2.css">
<!--PHP SCRIPT -->
<?php
session_start();
include_once("config.php");
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
if(strlen($_POST["fname"])<5)
$ferror="Length of firstname should be at least 5 ";
else
$fok="";
if(strlen($_POST["lname"])<5)
$lerror="Length of lastname should be at least 5 ";
else
$lok="";
$un=$_POST["uname"];
$result= $mysqli->query("SELECT * FROM user_info where username='$un'");
$r=0;
if(strcmp($_POST["pass"],$_POST["rpass"])!=0)
$pmr="Password doesnt match";
else
{
if(strlen($_POST["pass"])>5)
$pok="";
else
$pmr="Length of password must be at least 6";
}
while($res = $result->fetch_object())
{
$r++;
}
if($r>0)
$uerror="Username allready exist";
else
{ if(strlen($un)<5)
$uerror="Length of username should be at least 5 ";
else
$nok="";
}
}
if(!isset($_POST['gender']))
{
$error="Length of username should be at least 5 ";
}
if(isset($fok)&&isset($lok)&&isset($nok)&&isset($pok))
{
$fn=$_POST["fname"];
$ln=$_POST["lname"];
$un=$_POST["uname"];
$ps=$_POST["pass"];
$em=$_POST["email"];
$noi=$_POST["noi"];
$mn=$_POST["numb"];
$gender=$_POST["gender"];
$age=$_POST["age"];
$mysqli->query("insert into user_info (first_name,last_name,username,email,age,institute,mobile,gender) values('$fn','$ln','$un','$em',$age,'$noi','$mn','$gnd')");
$mysqli->query("insert into login_info (username,password,type) values('$un','$ps',0)");
header('Location:success.php');
}
?>
</head>
<body>
<!-- partial:index.partial.html -->
<div class="container">
<form id="contact" name="reg" method="POST" action="<?php $_SERVER['PHP_SELF'];?>">
<h3>Sign Up</h3>
<h4>Crime Reporting System</h4>
<fieldset>
First name <input type="text" name="fname" id="fn" onblur="fnvalidate() >
<span id="fnp"> <? if(isset($ferror)) echo $ferror;?> </span>
<br><br>
</fieldset>
Last name <input type="text" name="lname" id="ln" onblur="lnvalidate()">
<span id="lnp"> <? if(isset($lerror)) echo $lerror;?> </span>
<br><br>
Username <input type="text" name="uname" id="un" onblur="unvalidate()">
<span id="unp" style="color: red;"> <? if(isset($uerror)) echo $uerror;?> </span>
<br><br>
Email <input type="email" name="email" id="em" onblur="emvalidate()">
<span id="emp" style="color: red;"> <? if(isset($emerror)) echo $emerror;?> </span>
<br><br>
Age <input type="text" name="age" id="ag" onblur="emvalidate()">
<span id="agp"></span>
<br><br>
Password
<input type="password" name="pass" id="ps" onblur="emvalidate()"><br><br>
<span id="psp"></span>
Retype Password
<input type="password" name="rpass" id="rps" onblur="emvalidate()">
<span id="rsp"><? if(isset($pmr)) echo $pmr;?> </span>
<br><br>
Gender:<br>
Male: <input type="radio" name="gender" value="male" checked>
Female: <input type="radio" name="gender" value="female">
<br>
<br>
Contact number <input type="text" name="numb">
<br>
<br>
<fieldset>
<button name="submit" type="submit" id="contact-submit" value="submit" data-submit="...Sending">Submit</button>
</fieldset>
<p class="copyright"></p>
</form>
</div>
<!-- partial -->
</body>
<script>
function fnvalidate()
{ document.getElementById("fnp").innerHTML="";
var str=document.getElementById("fn").value;
if(str.length<5)
document.getElementById("fnp").innerHTML="Length of firstname should be atleast 5";
}
function numvali()
{
document.getElementById("fnp").innerHTML="";
var str=document.getElementById("numg").value;
if(str.length<11)
document.getElementById("nup").innerHTML="Invalid mobile number";
}
function lnvalidate()
{ document.getElementById("lnp").innerHTML="";
var str=document.getElementById("ln").value;
if(str.length<5)
document.getElementById("lnp").innerHTML="Length of lastname should be atleast 5";
}
function unvalidate() {
document.getElementById("unp").innerHTML="";
var str=document.getElementById("un").value;
if(str.length<5)
document.getElementById("unp").innerHTML="Length of username should be atleast 5";
if (str == "") {
document.getElementById("txtHint").innerHTML = "";
return;
} else {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("unp").innerHTML = this.responseText;
}
};
xmlhttp.open("GET","usercheck.php?q="+str,true);
xmlhttp.send();
}
}
function emvalidate()
{
}
</script>
</html>