-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateIncidentU.php
154 lines (119 loc) · 5.43 KB
/
updateIncidentU.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
<?php
ob_start();
include('./partials/headerSection.php')
?>
<div class="main">
<?php include('partials/sideMenuU.php')?>
<div class="mainContent">
<div class="topSection flex">
<div class="dashboardTitle">
<h1>Update Incident Page</h1>
</div>
<div class="userBox flex">
<a href="index.php">
<div class="adminImage">
<img src="./assets/images/pp.jpg" alt="Admin Image">
</div>
</a>
<div class="userName">
<span>Administrator</span>
<small><?php
if(isset($_SESSION['firstName'])){
echo $_SESSION['firstName'];
}
?></small>
</div>
<i class="uil uil-bell icon"></i>
</div>
</div>
<div class="body">
<div class="overViewDiv">
<div class="intro flex" >
<h3 class="title">Fill the fields to update current Incident!</h3>
<div class="addBtn">
<a href="incidentsU.php">
<span>View Incidents</span>
</a>
</div>
</div>
</div>
<div class="mainItems">
<div class="addCaseContainer flex">
<div class="rowsDiv">
<?php
// Get the id================>
$incidentId = $_GET['id'];
$sql = "SELECT * FROM incident_types WHERE id=$incidentId";
$res = mysqli_query($conn, $sql);
if($res==true){
$count = mysqli_num_rows($res);
if($count == 1){
while($row = mysqli_fetch_assoc($res)){
$incidentType = $row['inctype_name'];
$updatedDate = $row['added_on'];
$updatedBy = $row['added_by'];
$adminPassword = $row['admin_password'];
}
}
else{
header('location:' .SITERURL. 'incidentsU.php');
exit();
}
}
?>
<form action="" method="POST">
<div class="row">
<label for="incType">Incident Type</label></label>
<input type="text" id="incType" name="incType" value="<?php echo $incidentType ?>">
</div>
<div class="row">
<label for="incDate">Updated On</label>
<input type="datetime-local" id="incDate" name="incDate" value="<?php echo $updatedDate ?>">
</div>
</div>
<div class="rowsDiv">
<div class="row">
<label for="reporterName">Updated By</label>
<input type="text" id="reporterName" name="reporterName" value="<?php echo $updatedBy ?>">
</div>
<div class="row">
<input type="hidden" name="updateID" value="<?php echo $incidentId ?>">
<input type="submit" name="submit" id="submitBtn" value="Update">
</div>
</div>
</form>
<?php
if(isset($_POST['submit'])){
// Create input variables============>
$incidentType = $_POST['incType'];
$reporterName = $_POST['reporterName'];
$incDate = $_POST['incDate'];
// Insert Data to the table ===============>
$sql = "UPDATE incident_types SET
inctype_name = '$incidentType',
added_by = '$reporterName',
added_on = '$incDate'
WHERE id=$incidentId
";
// Execute query =================>
$result = mysqli_query($conn, $sql);
// Check if query is executed ============>
if($result == True){
$_SESSION['updateIncident'] = '<span class="success">Incident Updated Successfully!</span>';
header('location:' .SITEURL. 'incidentsU.php');
exit();
}
else{
$_SESSION['updateIncident'] = '<span class="fail">Failed to update incident!</span>';
header('location:' .SITEURL. 'incidentsU.php');
exit();
}
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include('partials/footer.php')?>