-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregistration.php
More file actions
200 lines (200 loc) · 5.54 KB
/
registration.php
File metadata and controls
200 lines (200 loc) · 5.54 KB
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
200
<html>
<head>
<?php include "header.php"; ?>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<style>
.content{
margin: 5px;
padding : 4rem -10rem 2rem 3rem;
box-shadow:0 0 5px 10px rgba(0,0,0, .05);
}
.form-control
{
display: block;
width:300px;
font-size:1rem;
font-weight:400;
line-height:1.5;
border-color:#00ac96;
border-style:solid;
border-width:0 0 1px 0;
padding : 0;
color:#495057;
height:auto;
border-radius:0;
background-color: #fff;
background-clip: padding-box;
}
.form-group{
margin-left:100px;
}
.btn-primary{
background-color:white;
border-color:#00ac96;
color:#00ac96;
}
.btn-primary:hover{
background-color:#00ac96;
color:#fff;
}
</style>
</head>
<style>
.error
{
color: #FF0000;
}
</style>
<body>
<?php include "nav1.php"; ?>
<?php
$username = $emailid = $pwd = $city = $contact = $address = "";
$userErr = $emailErr = $pwdErr = $cityErr = $conErr = $addErr = "";
function test_input($data)
{
$data = trim($data); //remove space
$data = stripslashes($data); //removes backslashes
$data = htmlspecialchars($data); //remove special characters
return $data;
}
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if (empty($_POST["username"]))
{
$userErr ="User name is required";
}
else
{
$username=test_input($_POST["username"]);
}
if (empty($_POST["pwd"]))
{
$pwdErr ="Password is required";
}
else
{
$pwd=test_input($_POST["pwd"]);
}
if (empty($_POST["city"]))
{
$cityErr ="City is required";
}
else
{
$city=test_input($_POST["city"]);
}
if (empty($_POST["address"]))
{
$addErr ="Address is required";
}
else
{
$address=test_input($_POST["address"]);
}
if (empty($_POST["emailid"]))
{
$emailErr = "Email is required";
}
else
{
$emailid = test_input($_POST["emailid"]);
if (!filter_var($emailid,FILTER_VALIDATE_EMAIL))
{
$emailErr = "Invalid email format";
}
}
if(empty($_POST["contact"]))
{
$conErr="Contact number is required";
}
else
{
$contact=test_input($_POST["contact"]);
if(!preg_match("/^[0-9]{10}+$/",$contact))
{
$conErr="Contact number should be in digits and only 10 digits";
}
}
}
?>
<div class="container" style = "margin-top : 70px">
<div class ="row content">
<div class ="col-md-6 mb-3">
<img src = "myimages2/registration1.jpg" width="550" height="550" style="margin-top:70px">
</div>
<div clas="col-md-6">
<h2 class="signin-text mb-3" style = "font-family : 'Monotype Corsiva' ; color:#E6120E">Registration</h2>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<div class="form-group">
<label><b>UserName</b></label><span class="error">* <?php echo $userErr;?></span>
<input type = text name="username" class="form-control" placeholder="Enter your name here" value="<?php echo $username;?>">
</div>
<div class="form-group">
<label><b>Password</b></label><span class="error">* <?php echo $pwdErr;?></span>
<input type = password name="pwd" class="form-control" placeholder="Enter Password" value="<?php echo $pwd;?>">
</div>
<div class="form-group">
<label><b>City</b></label><span class="error">* <?php echo $cityErr;?></span>
<input type = text name="city" class="form-control" placeholder="Enter City" value="<?php echo $city?>">
</div>
<div class="form-group">
<label><b>Address</b></label><span class="error">* <?php echo $addErr;?></span>
<textarea name="address" class="form-control" placeholder="Enter your address" value="<?php echo $address;?>"></textarea>
</div>
<div class="form-group">
<label><b>Email ID</b></label><span class="error">* <?php echo $emailErr;?></span>
<input type = text name="emailid" class="form-control" placeholder="Enter your email" value="<?php echo $emailid;?>">
</div>
<div class="form-group">
<label><b>Contact</b></label><span class="error">* <?php echo $conErr;?></span>
<input type = text name="contact" class="form-control" placeholder="Enter Your Contact Number" value="<?php echo $contact;?>">
<br></div>
<div class="form-group">
<input type = submit name = submit value = Submit class="btn btn-primary">
</div>
</form>
</div>
</div>
</div>
</body>
</html>
<?php
include "dbconfigure.php";
if(isset($_POST['submit']))
{
if($userErr=="" && $pwdErr=="" && $cityErr=="" && $addErr=="" && $emailErr=="" && $conErr=="")
{
$username = $_POST['username'];
$pwd = $_POST['pwd'];
$city = $_POST['city'];
$address = $_POST['address'];
$emailid = $_POST['emailid'];
$contact = $_POST['contact'];
$query = "insert into siteuser (username,pwd,city,address,emailid,contact) values('$username','$pwd','$city','$address','$emailid','$contact')";
$n = my_iud($query);
if($n==1)
{
echo
'<script>
swal({
text: "Registration successfull!",
icon: "success",
}).then(function() {
window.location.href = "login.php";
});
</script>';
}
else
{
echo '<script>alert("Something went wrong");
</script>';
}
}
}
?>