-
Notifications
You must be signed in to change notification settings - Fork 2
/
registration.php
149 lines (112 loc) · 3.65 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
<html>
<head>
<link rel="stylesheet" href="carrental.css">
<style>
.error {color: red;}
</style>
</head>
<body>
<div class="navbar">
<a href="carrental.php">Home</a>
<a href="tarrif.php">Tarrifs</a>
<a href="#">About us</a>
<a href="#">Contact us</a>
<a href="login.php" class="right">Login</a>
<a href="registration.php" class="right">Sign Up</a>
</div>
<?php
include 'dbcreation.php';
$cfname = $cdob = $cphone = $cgender = $cemail = $cuname = $cpwd = "";
if(isset($_POST['register'])){
if (empty($_POST["fname"])) {
$cfname = "Name is required";
}else {
$fname = $_POST['fname'];
}
$lname = $_POST['lname'];
if (empty($_POST["dob"])) {
$cdob = "DOB is required";
}else {
$dob = $_POST['dob'];
}
if (empty($_POST["phone"])) {
$cphone = "phone number is required";
}else {
$phone= $_POST['phone'];
}
if (empty($_POST["M"])) {
$cgender = "gender is required";
}else {
$gender = $_POST['M'];
}
if (empty($_POST["email"])) {
$cemail = "email is required";
}else {
$email= $_POST['email'];
}
if (empty($_POST["uname"])) {
$cuname = "username is required";
}else {
$uname= $_POST['uname'];
}
if (empty($_POST["pwd"])) {
$cpwd = "password is required";
}else {
$pwd = $_POST['pwd'];
}
function validate_phone_number($phone)
{
// Allow +, - and . in phone number
$filtered_phone_number = filter_var($phone, FILTER_SANITIZE_NUMBER_INT);
// Remove "-" from number
$phone_to_check = str_replace("-", "", $filtered_phone_number);
// Check the lenght of number
// This can be customized if you want phone number from a specific country
if (strlen($phone_to_check) < 10 || strlen($phone_to_check) > 14) {
return false;
} else {
return true;
}
}
$city= $_POST['city'];
$country= $_POST['state'];
$state =$_POST['country'];
if(!empty($fname) && !empty($dob) && !empty($phone) && !empty($gender) && !empty($email) && !empty($pwd) && validate_phone_number($phone) == true){
mysqli_select_db($con,"userinformation");
$query="insert into registerhere values('$fname','$lname','$phone','$gender','$dob','$email','$uname','$pwd','$city','$country','$state')";
if(mysqli_query($con,$query))
{
echo "data inserted successfully<br>";
}
else{
echo "data not inserted".mysqli_error($con);
}
}
}
?>
<div class="bg-image"></div>
<div class="bg-text">
<center>
<pre>
<h3> Registration form</h3>
<hr>
<form method="post">
First Name : <input type ="text" name="fname" /><span class = "error">*<?php echo $cfname;?></span> Last Name : <input type ="text" name="lname">
Date of birth : <input type = "text" name = "dob" placeholder = "yyyy-mm-dd" /><span class = "error">*<?php echo $cdob;?></span>
Mobile Number : <input type ="text" name="phone" /><span class = "error">*<?php echo $cphone;?></span>
Gender : <input type ="radio" name="M" value = "M" default/>Male
<input type ="radio" name="M" value = "FM" />Female<span class = "error">*<?php echo $cgender;?></span>
Email : <input type ="text" name="email" placeholder="abc@gmail.com" /><span class = "error">* <?php echo $cemail;?></span>
User Name : <input type ="text" name="uname" /><span class = "error">*<?php echo $cuname;?></span>
Password : <input type ="password" name="pwd" /><span class = "error">*<?php echo $cpwd;?></span>
City : <input type ="text" name="city" />
State : <input type ="text" name="state" />
Country : <input type ="text" name="country"/>
<input type ="submit" name="register" value="submit"/>
</form>
</pre>
</center>
</div>
</div>
</body>
</html>