-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathregistration.php
153 lines (134 loc) · 3.48 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>XCompany</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="topnav">
<a href="index.php">Home</a>
<a href="login.php">Login</a>
<a href="registration.php">Registration</a>
</div>
<div class>
<h4 style="text-align: center">Registration</h1>
<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="POST">
<table align="center">
<tr>
<td>Name</td>
<td><input type="text" name="name" placeholder="Give your name"/></td>
</tr>
<tr>
<td>Email</td>
<td><input type="text" name="email" placeholder="Give your email"/></td>
</tr>
<tr>
<td>User Name</td>
<td><input type="text" name="userName"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password" placeholder="Give your password"/></td>
</tr>
<tr>
<td>Confirm Password</td>
<td><input type="password" name="cpassword" placeholder="Retype your password"></td>
</tr>
<tr>
<td>Gender</td>
<td>
<input type="radio" name="gender" value="male">Male
<input type="radio" name="gender" value="female">Female
<input type="radio" name="gender" value="other">Other
</td>
</tr>
<tr>
<td>Date of Birth</td>
<td><input type="text" name="dob"></td>
<td>(dd/mm/yyy)</td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="register" value="Register"/>
<input type="reset" value="Reset"></td>
</tr>
</table>
</form>
</div>
<div class="footer">
<p>Copyright © 2020</p>
</div>
</body>
</html>
<?php
if(isset($_POST['register']))
{
$name=$_POST['name'];
$email=$_POST['email'];
$userName=$_POST['userName'];
$password=$_POST['password'];
$cpassword=$_POST['cpassword'];
$gender=$_POST['gender'];
$dob=$_POST['dob'];
if($password==$cpassword)
{
$con=mysqli_connect("localhost","root","","testdb");
if(!$con)
{
die("Connection Error: ".mysqli_connect_error()."<br/>");
}
//Row Insert
$sql="INSERT INTO customers(name,email,userName,password,gender,dob) VALUES('$name','$email','$userName','$password','$gender','$dob')";
if(mysqli_query($con,$sql))
{
header("Location:login.php");
}
else
{
echo "Error in inserting: ".mysqli_error($con);
}
mysqli_close($con);
}
else
{
echo "Password Mismatch";
}
}
//Row Update
// $sql="UPDATE customers SET name='Loki' WHERE id=2";
// if(mysqli_query($con,$sql))
// {
// echo "Successfully row updated..<br/>";
// }
// else
// {
// echo "Error in updating: ".mysqli_error($con);
// }
//Row Delete
// $sql="DELETE FROM customers WHERE id=2";
// if(mysqli_query($con,$sql))
// {
// echo "Successfully row deleted..<br/>";
// }
// else
// {
// echo "Error in deleting: ".mysqli_error($con);
// }
//Retrieve Data
// $sql="SELECT * FROM customers WHERE id=1";
// $result=mysqli_query($con,$sql);
// if(mysqli_num_rows($result)>0)
// {
// while($row=mysqli_fetch_array($result))
// {
// //echo "Id: ".$row[0]." Name: ".$row[1]."<br/>";
// echo "Id: ".$row['id']." Name: ".$row['name']."<br/>";
// }
// }
// else
// {
// echo "No data found.<br/>";
// }
?>