-
Notifications
You must be signed in to change notification settings - Fork 0
/
customerUpdate.php
212 lines (187 loc) · 5.98 KB
/
customerUpdate.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
<?php
include("header.php");
if(!isset($_SESSION['customerid']))
{
echo "<script>window.location='index.php';</script>";
}
if($_SESSION['randnumber'] == $_POST['randnumber'])
{
if(isset($_POST['submit']))
{
$sql ="UPDATE customer SET `customer_name`='$_POST[customername]', `address`='$_POST[address]', `state_id`='$_POST[state]', `city_id`='$_POST[city]', `pincode`='$_POST[pincode]', `contact_no`='$_POST[cntctnum]', `mobile_no`='$_POST[mblnum]', `email_id`='$_POST[email_id]', `customer_type`='$_POST[customertype]', `status`='$_POST[status]' WHERE customer_id='$_SESSION[customerid]'";
if(!mysqli_query($con,$sql))
{
echo "Error in mysqli query";
}
else
{
echo "<script>alert('Customer Profile updated successfully...');</script>";
}
}
}
$randnumber = rand();
$_SESSION['randnumber'] = $randnumber;
if(isset($_SESSION['customerid']))
{
$sql = "SELECT * FROM customer WHERE customer_id='$_SESSION[customerid]'";
$qsql = mysqli_query($con,$sql);
$rsedit = mysqli_fetch_array($qsql);
}
?>
<main id="main">
<!-- ======= Cta Section ======= -->
<section id="cta" class="cta">
<div class="container">
<div class="text-center" data-aos="zoom-in">
<br><br>
<h3>Customer Profile</h3>
</div>
</div>
</section><!-- End Cta Section -->
<!-- ======= Contact Section ======= -->
<section id="contact" class="contact">
<div class="container">
<div class="row">
<div class="col-lg-12" data-aos="fade-up" data-aos-delay="100">
<div class="info mt-4">
<center><h4>Keep Your Profile Updated Here..</h4></center>
<form method="post" action="" name="frmcstupdate" onsubmit="return validatecstupdate()">
<input type="hidden" name="randnumber" value="<?php echo $randnumber; ?>" >
<div class="form-row">
<div class="col-md-6 form-group">
Customer Name <font color="#FF0000">*</font>
<input type="text" name="customername" id="customername" value="<?php echo $rsedit['customer_name']; ?>" class="form-control" >
</div>
<div class="col-md-6 form-group">
Email ID <font color="#FF0000">*</font>
<input type="email" name="email_id" id="email_id" value="<?php echo $rsedit['email_id']; ?>" class="form-control" >
</div>
<div class="col-md-12 form-group">
Address <font color="#FF0000">*</font>
<textarea name="address" id="address" class="form-control"><?php echo $rsedit['address']; ?></textarea>
</div>
<div class="col-md-6 form-group">
State <font color="#FF0000"> *</font>
<span id='loadstate'><select name="state" id="state" class="form-control">
<option value="">Select</option>
<?php
$sql2 = "SELECT * FROM state where status='Active'";
$qsql2 =mysqli_query($con,$sql2);
while($rssql2 = mysqli_fetch_array($qsql2))
{
if($rssql2['state_id'] == $rsedit['state_id'])
{
echo "<option value='$rssql2[state_id]' selected>$rssql2[state]</option>";
}
else
{
echo "<option value='$rssql2[state_id]'>$rssql2[state]</option>";
}
}
?>
</select></span>
</div>
<div class="col-md-6 form-group">
City <font color="#FF0000"> *</font>
<span id='loadcity'><select name="city" id="city" class="form-control">
<option value="">Select</option>
<?php
$sql3 = "SELECT * FROM city where status='Active'";
$qsql3 =mysqli_query($con,$sql3);
while($rssql3 = mysqli_fetch_array($qsql3))
{
if($rssql3['city_id'] == $rsedit['city_id'] )
{
echo "<option value='$rssql3[city_id]' selected>$rssql3[city]</option>";
}
else
{
echo "<option value='$rssql3[city_id]'>$rssql3[city]</option>";
}
}
?>
</select></span>
</div>
<div class="col-md-6 form-group">
Pincode <font color="#FF0000"> *</font>
<input type="number" name="pincode" id="pincode" value="<?php echo $rsedit['pincode']; ?>" class="form-control">
</div>
<div class="col-md-6 form-group">
Contact Number <font color="#FF0000"> *</font>
<input type="number" name="cntctnum" id="cntctnum" value="<?php echo $rsedit['contact_no']; ?>" class="form-control">
</div>
<div class="col-md-6 form-group">
Mobile Number <font color="#FF0000"> *</font>
<input type="number" name="mblnum" id="mblnum" value="<?php echo $rsedit['mobile_no']; ?>" class="form-control">
</div>
<div class="col-md-6 form-group">
Customer Type <font color="#FF0000"> *</font>
<select name="customertype" id="customertype" class="form-control" >
<option value="">Select</option>
<?php
$arr= array("Wholesaler","Retailer","Consumer");
foreach($arr as $val)
{
if($rsedit['customer_type'] == $val)
{
echo "<option value='$val' selected >$val</option>";
}
else
{
echo "<option value='$val'>$val</option>";
}
}
?>
</select>
</div>
<div class="col-md-6 form-group">
<?php
if(isset($_SESSION['adminid']))
{
?>
Status <font color="#FF0000"> *</font>
<select name="status" id="status">
<option value="">Select</option>
<?php
$arr= array("Active","Inactive");
foreach($arr as $val)
{
if($rsedit['status'] == $val)
{
echo "<option value='$val' selected >$val<option>";
}
else
{
echo "<option value='$val'>$val<option>";
}
}
?>
</select>
<?php
}
else
{
?>
<input type="hidden" name="status" value="Active" >
<?php
}
?>
</div>
</div>
<hr>
<button type="submit" name="submit" id="submit" class="btn btn-info btn-lg btn-block" >Update Profile</button>
</form>
</div>
</div>
</div>
</div>
</section><!-- End Contact Section -->
</main><!-- End #main -->
<?php
include("footer.php");
?>
<script>
$(document).ready( function () {
$('#datatable').DataTable();
} );
</script>