-
Notifications
You must be signed in to change notification settings - Fork 0
/
customer.php
254 lines (227 loc) · 9.37 KB
/
customer.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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<?php
include("header.php");
if (!isset($_SESSION['staffid'])) {
//echo "<script>window.location='index.php';</script>";
}
if (isset($_POST['submit'])) {
$password = md5($_POST['password']);
if (isset($_GET['editid'])) {
$sql = "UPDATE customer SET customer_name='$_POST[customer_name]',address='$_POST[address]',city='$_POST[city]',pincode='$_POST[pincode]',contact_no='$_POST[contact_no]',email_id='$_POST[email_id]',password='$password',status='$_POST[status]' WHERE customer_id='$_GET[editid]'";
$qsql = mysqli_query($con, $sql);
if (mysqli_affected_rows($con) == 1) {
echo "<script>alert('Customer record updated successfully..');</script>";
} else {
echo mysqli_error($con);
}
} else {
$sql = "INSERT INTO customer (customer_name,address,city,pincode,contact_no,email_id,password,status) values('$_POST[customer_name]','$_POST[address]','$_POST[city]','$_POST[pincode]','$_POST[contact_no]','$_POST[email_id]','$password','$_POST[status]')";
$qsql = mysqli_query($con, $sql);
if (mysqli_affected_rows($con) == 1) {
echo "<script>alert('Customer details accepted..');</script>";
echo "<script>window.location='customer.php';</script>";
} else {
echo "<script>alert('Customer account already registered with this Email ID.....');</script>";
//echo mysqli_error($con);
}
}
}
?>
<?php
if (isset($_GET['editid'])) {
$sqledit = "SELECT * FROM customer where customer_id='$_GET[editid]'";
$qsqledit = mysqli_query($con, $sqledit);
$rsedit = mysqli_fetch_array($qsqledit);
}
?>
<!-- Sub Banner Start -->
<div class="mg_sub_banner">
<div class="container">
<h2>Customer Details </h2>
</div>
</div>
<!-- Sub Banner Start -->
<!-- Main Contant Wrap Start -->
<div class="iqoniq_contant_wrapper">
<section>
<div class="container">
<form method="post" action="" onsubmit="return validateform()">
<div class="row">
<!-- Hotel Destination Start -->
<div class="col-md-12 col-sm-12">
<div class="mg_hotel_destination fancy-overlay">
<div class="text">
<div class="row">
<div class="col-md-2 boldfont">
Name
</div>
<div class="col-md-10">
<input type="text" placeholder="Enter Your Name" name="customer_name" id="customer_name" class="form-control" value="<?php echo $rsedit['customer_name']; ?>"><span id="errcustomer_name" class="errmsg flash"></span>
</select>
</div>
</div><br>
<div class="row">
<div class="col-md-2 boldfont">
Password
</div>
<div class="col-md-10">
<input type="password" placeholder="Enter Password" name="password" id="password" class="form-control"><span id="errpassword" class="errmsg flash"></span>
</div>
</div><br>
<div class="row">
<div class="col-md-2 boldfont">
Confirm Password
</div>
<div class="col-md-10">
<input type="password" placeholder="confirm Password" name="cpassword" id="cpassword" class="form-control"><span id="errcpassword" class="errmsg flash"></span>
</div>
</div><br>
<div class="row">
<div class="col-md-2 boldfont">
Address
</div>
<div class="col-md-10">
<textarea placeholder="Enter Address" name="address" id="address" class="form-control"><?php echo $rsedit['address']; ?></textarea><span id="erraddress" class="errmsg flash"></span>
</select>
</div>
</div><br>
<div class="row">
<div class="col-md-2 boldfont">
City
</div>
<div class="col-md-10">
<input type="text" placeholder="Enter City" name="city" id="city" class="form-control" value="<?php echo $rsedit['city']; ?>"><span id="errcity" class="errmsg flash"></span>
</select>
</div>
</div><br>
<div class="row">
<div class="col-md-2 boldfont">
Pincode
</div>
<div class="col-md-10">
<input type="text" placeholder="Enter Pincode" name="pincode" id="pincode" class="form-control" value="<?php echo $rsedit['pincode']; ?>"><span id="errpincode" class="errmsg flash"></span>
</div>
</div><br>
<div class="row">
<div class="col-md-2 boldfont">
Contact No
</div>
<div class="col-md-10">
<input type="text" placeholder="Enter Contact Number" name="contact_no" id="contact_no" class="form-control" value="<?php echo $rsedit['contact_no']; ?>"><span id="errcontact_no" class="errmsg flash"></span>
</div>
</div><br>
<div class="row">
<div class="col-md-2 boldfont">
Email Id
</div>
<div class="col-md-10">
<input type="text" placeholder="Enter Email Id" name="email_id" id="email_id" class="form-control" value="<?php echo $rsedit['email_id']; ?>"><span id="erremail_id" class="errmsg flash"></span>
</div>
</div><br>
<div class="row">
<div class="col-md-2 boldfont">
Status
</div>
<div class="col-md-10">
<select name="status" id="status" class="form-control">
<option value="">Select status</option>
<?php
$arr = array("Active", "Inactive");
foreach ($arr as $val) {
if ($val == $rsedit['status']) {
echo "<option value='$val' selected>$val</option>";
} else {
echo "<option value='$val'>$val</option>";
}
}
?>
</select><span id="errstatus" class="errmsg flash"></span>
</div>
</div><br>
<div class="row">
<div class="col-md-2">
</div>
<div class="col-md-10">
<input type="submit" name="submit" id="submit" class="form-control btn btn-warning " style="width: 250px;height:50px;">
</div>
</div><br>
</form>
</div>
</div>
</div>
<!-- Hotel Destination End -->
</div>
</div>
</section>
</div>
<!-- Main Contant Wrap End -->
<?php
include("footer.php");
?>
<script>
function validateform() {
var alphaExp = /^[a-zA-Z]+$/; //Variable to validate only alphabets
var alphaspaceExp = /^[a-zA-Z\s]+$/; //Variable to validate only alphabets with space
var alphanumericExp = /^[a-zA-Z0-9]+$/; //Variable to validate only alphanumerics
var numericExpression = /^[0-9]+$/; //Variable to validate only numbers
var emailpattern = /^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/; //For email id
var i = 0;
$(".errmsg").empty();
if (!document.getElementById("customer_name").value.match(alphaspaceExp)) {
document.getElementById("errcustomer_name").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i> Entered customer name is not valid";
i = 1;
}
if (document.getElementById("customer_name").value == "") {
document.getElementById("errcustomer_name").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i> Customer name should not be empty";
i = 1;
}
if (document.getElementById("password").value.length < 8) {
document.getElementById("errpassword").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i> Password should contain more than 8 characters";
i = 1;
}
if (document.getElementById("password").value == "") {
document.getElementById("errpassword").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i>Password should not be empty...";
i = 1;
}
if (document.getElementById("password").value != document.getElementById("cpassword").value) {
document.getElementById("errcpassword").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i>Password and confirm password not matching...";
i = 1;
}
if (document.getElementById("cpassword").value == "") {
document.getElementById("errcpassword").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i>Confirm Password should not be empty...";
i = 1;
}
if (document.getElementById("address").value == "") {
document.getElementById("erraddress").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i>Enter the address";
i = 1;
}
if (document.getElementById("city").value == "") {
document.getElementById("errcity").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i>Enter the city name";
i = 1;
}
if (document.getElementById("pincode").value.match(numericExpression)) {
document.getElementById("errpincode").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i>Pincode should be entered";
i = 1;
}
if (document.getElementById("contact_no").value.match(numericExpression)) {
document.getElementById("errcontact").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i>Enter the Contact number";
i = 1;
}
if (!document.getElementById("email_id").value.match(emailpattern)) {
document.getElementById("erremail_id").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i> Entered Email ID is not valid...";
i = 1;
}
if (document.getElementById("email_id").value == "") {
document.getElementById("erremail_id").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i>Email ID should not be empty...";
i = 1;
}
if (document.getElementById("status").value == "") {
document.getElementById("errstatus").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i>Status should not be empty...";
i = 1;
}
if (i == 0) {
return true;
} else {
return false;
}
}
</script>