-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_booking.php
60 lines (51 loc) · 2.03 KB
/
update_booking.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
<?php
include('header.php');
include('dbcon.php');
$row = array();
if (isset($_GET['id'])) {
$id = $_GET['id'];
$query = "SELECT * FROM booking WHERE bookingID = '$id'";
$result = mysqli_query($connection, $query);
if (!$result) {
die("Query Failed: " . mysqli_error($connection));
} else {
$row = mysqli_fetch_assoc($result);
}
}
if (isset($_POST['update_booking'])) {
if (isset($_GET['id'])) {
$idnew = $_GET['id'];
}
$purpose = $_POST['purpose'];
$date = $_POST['date'];
$starttime = $_POST['start_time'];
$endtime = $_POST['end_time'];
$query = "UPDATE booking SET Purpose = '$purpose', Date = '$date', startTime = '$starttime', endTime = '$endtime' WHERE bookingID = '$idnew'";
$result = mysqli_query($connection, $query);
if (!$result) {
die("Query failed: " . mysqli_error($connection));
} else {
header('location:index.php?update_msg=You have successfully updated the data.');
}
}
?>
<form action="update_booking.php?id=<?php echo $id; ?>" method="post">
<div class="form-group">
<label for="purpose">Purpose</label>
<input type="text" name="purpose" class="form-control" value="<?php echo isset($row['Purpose']) ? $row['Purpose'] : ''; ?>">
</div>
<div class="form-group">
<label for="date">Date</label>
<input type="text" name="date" class="form-control" value="<?php echo isset($row['Date']) ? $row['Date'] : ''; ?>">
</div>
<div class="form-group">
<label for="start_time">Start Time</label>
<input type="text" name="start_time" class="form-control" value="<?php echo isset($row['startTime']) ? $row['startTime'] : ''; ?>">
</div>
<div class="form-group">
<label for="end_time">End Time</label>
<input type="text" name="end_time" class="form-control" value="<?php echo isset($row['EndTime']) ? $row['EndTime'] : ''; ?>">
</div>
<input type="submit" class="btn btn-success" name="update_booking" value="UPDATE">
</form>
<?php include('footer.php'); ?>