-
Notifications
You must be signed in to change notification settings - Fork 0
/
reg.php
145 lines (145 loc) · 4.42 KB
/
reg.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
<script type="text/javascript" language="javascript">
function first()
{
var x1=document.getElementById("firstname").value;
if(x1.length>20)
{
var a=document.createElement("p");
a.setAttribute("id","invalidfirst");
document.getElementById("first").appendChild(a);
document.getElementById("invalidfirst").innerHTML="Maximum of 20 characters allowed";
document.getElementById("sub").disabled=true;
return false;
}
else
{
var b=document.getElementById("invalidfirst");
document.getElementById("first").removeChild(b);
document.getElementById("sub").disabled=false;
return true;
}
}
function last()
{
var x2=document.getElementById("lastname").value;
if(x2.length>20)
{
var a=document.createElement("p");
a.setAttribute("id","invalidlast");
document.getElementById("last").appendChild(a);
document.getElementById("invalidlast").innerHTML="Maximum of 20 characters allowed";
document.getElementById("sub").disabled=true;
return false;
}
else
{
var b=document.getElementById("invalidlast");
document.getElementById("last").removeChild(b);
document.getElementById("sub").disabled=false;
return true;
}
}
function pass()
{
var p=document.getElementById("password").value;
if(/^(?=.*[0-9])(?=.*[!@#$%^&*])[a-zA-Z0-9!@#$%^&*]{7,15}$/.test(p))
{
var b=document.getElementById("invalidpassword");
document.getElementById("pass").removeChild(b);
document.getElementById("sub").disabled=false;
return (true);
}
var a=document.createElement("p");
a.setAttribute("id","invalidpassword");
document.getElementById("pass").appendChild(a);
document.getElementById("invalidpassword").innerHTML="Invalid Password";
document.getElementById("sub").disabled=true;
return (false);
}
function show()
{
var temp=document.getElementById("password");
if (temp.type=="password")
temp.type="text";
else
temp.type="password";
}
function show1()
{
var temp1=document.getElementById("confirmpassword");
if (temp1.type=="password")
temp1.type="text";
else
temp1.type="password";
}
function confirm()
{
var x1=document.getElementById("password").value;
var x2=document.getElementById("confirmpassword").value;
var b=document.createElement("p");
b.setAttribute("id","invalidpass");
document.getElementById("con").appendChild(b);
var a=document.createElement("p");
a.setAttribute("id","Validpass");
document.getElementById("con").appendChild(a);
if(x1==x2)
{
var b=document.getElementById("invalidpass");
document.getElementById("con").removeChild(b);
document.getElementById("Validpass").innerHTML="Passwords match";
document.getElementById("sub").disabled=false;
return true;
}
else
{
var a=document.getElementById("Validpass");
document.getElementById("con").removeChild(a);
document.getElementById("invalidpass").innerHTML="Passwords dont match";
document.getElementById("sub").disabled=true;
return false;
}
}
function mob()
{
var x1=document.getElementById("number").value;
if (x1.length==10)
{
var a=document.getElementById("invalidphone");
document.getElementById("num").removeChild(a);
document.getElementById("sub").disabled=false;
return true;
}
else
{
var a=document.createElement("p");
a.setAttribute("id","invalidphone");
document.getElementById("num").appendChild(a);
document.getElementById("invalidphone").innerHTML="Mobile number should be of 10 digits";
document.getElementById("sub").disabled=true;
return false;
}
}
</script>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "gossip";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$stmt = $conn->prepare("INSERT INTO users (firstname, lastname, password, email, mobile, age, gender) VALUES (?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param("ssssiis", $first, $last, $password, $email, $mobile, $age, $gender);
$first=$_POST["firstname"];
$last=$_POST["lastname"];
$password=$_POST["password"];
$email=$_POST["email"];
$mobile=$_POST["phone"];
$age=$_POST["age"];
$gender=$_POST["gen"];
$stmt->execute();
echo "New records created successfully";
$stmt->close();
$conn->close();
?>