-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_courier.php
117 lines (91 loc) · 3.52 KB
/
update_courier.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
<?php
include('CheckIfLogin.php');
include('connection.php');
include('navBar.php');
$c_id = $_GET['c_id'];
$c_name = $_GET['name'];
$status = $_GET['status'];
$pass = $_GET['PASSWORD'];
$c_contact = $_GET['contact'];
$c_location = $_GET['address'];
?>
<!DOCTYPE html>
<html >
<head>
<link rel="stylesheet" href="./Css/CourierFormStyling.css" />
<title>Upadte_courier</title>
</head>
<body>
<div class="container">
<form method="post" class="item1">
<h3 class="item1-1">Upadte Detail</h3>
<label for="id">Courier id:</label>
<input type="text" name="id" id="id" class="item1-2" value ="<?php echo $c_id; ?>" readonly/>
<label for="name">Courier Name:</label>
<input type="text" name="name" id="name" class="item1-2" value ="<?php echo $c_name; ?>" />
<label for="phone">Contact no:</label>
<input type="tel" name="ph" id="ph" class="item1-2" value ="<?php echo $c_contact; ?>"/>
<label for="location">Address:</label>
<input type="text" name="location" id="" value ="<?php echo $c_location; ?>">
<label for="password">password:</label>
<input type="text" name="password" id="" value ="<?php echo $pass; ?>">
<label for="">status:</label>
<select name="status" id="status">
<?php
if ($status == 'active') {
echo "<option value='active'>active</option>
<option value='inactive'>inactive</option>";
} else {
echo "<option value='inactive'>inactive</option>
<option value='active'>active</option>";
}
?>
</select>
<br />
<input type="submit" value="Submit" id="btn" name="enter" />
</form>
</div>
<?php
if (isset($_POST['enter'])) {
$c_id = $_POST['id'];
$c_name = $_POST['name'];
$c_location = $_POST['location'];
$c_contact = $_POST['ph'];
$pass = $_POST['password'];
$status = $_POST['status'];
//validation
if ( empty($c_location) || empty($c_contact) || empty($pass)) {
echo "<script>alert('Please fill all the fields')</script>";
exit();
}
if (strlen($c_contact) != 11) {
echo "<script>alert('Please enter valid contact number')</script>";
exit();
}
if (strlen($pass) < 5) {
echo"<script> alert('Password should be of atleast 5 characters'); </script>";
exit();
}
$sql = "select * from courier join assign using (c_id) where c_id = $c_id";
$result =$connect->query($sql);
if ($result->num_rows > 0 && $status == 'inactive') {
echo "<script>alert ('cant update status now courier have pending shipments');</script>";
exit();
} else {
$sql ="UPDATE `courier` SET `status`='$status',`PASSWORD`='$pass',`address`='$c_location',`contact`='$c_contact' WHERE c_id = $c_id";
$result =$connect->query($sql);
}
if ($result) {
echo "yes";
echo "<script>location.href='Manage_Courier.php'</script>";
} else {
echo "no";
echo "<script>location.href='Manage_Courier.php'</script>";
}
}
?>
</body>
</html>
<?php
include('footer.php');
?>