-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit_room.php
100 lines (98 loc) · 4.18 KB
/
edit_room.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
<!DOCTYPE html>
<?php
include("database.php");
?>
<html lang = "en">
<head>
<title>Hotel Online Reservation</title>
<meta charset = "utf-8" />
<meta name = "viewport" content = "width=device-width, initial-scale=1.0" />
<link rel = "stylesheet" type = "text/css" href = "../css/bootstrap.css " />
<link rel = "stylesheet" type = "text/css" href = "../css/style.css" />
</head>
<body>
<br />
<div class = "container-fluid">
<div class = "panel panel-default">
<div class = "panel-body">
<div class = "alert alert-info">Transaction / Room / Change Room</div>
<br />
<div class = "col-md-4">
<?php
$query = $db->query("SELECT * FROM `room` WHERE `room_id` = '$_REQUEST[room_id]'") or die(mysqli_error());
$fetch = $query->fetch_array();
?>
<form method = "POST" enctype = "multipart/form-data">
<div class = "form-group">
<label>Room Type </label>
<select class = "form-control" required = required name = "room_type">
<option value = "">Choose an option</option>
<option value = "Standard" <?php if($fetch['room_type'] == "Standard"){echo "selected";}?>>Standard</option>
<option value = "Superior" <?php if($fetch['room_type'] == "Superior"){echo "selected";}?>>Superior</option>
<option value = "Super Deluxe" <?php if($fetch['room_type'] == "Super Deluxe"){echo "selected";}?>>Super Deluxe</option>
<option value = "Jr. Suite" <?php if($fetch['room_type'] == "Jr. Suite"){echo "selected";}?>>Jr. Suite</option>
<option value = "Executive Suite" <?php if($fetch['room_type'] == "Executive Suite"){echo "selected";}?>>Executive Suite</option>
</select>
</div>
<div class = "form-group">
<label>Price </label>
<input type = "number" min = "0" max = "999999999" value = "<?php echo $fetch['price']?>" class = "form-control" name = "price" />
</div>
<div class = "form-group">
<label>Photo </label>
<div id = "preview" style = "width:150px; height :150px; border:1px solid #000;">
<img src = "photo/<?php echo $fetch['photo']?>" id = "lbl" width = "100%" height = "100%"/>
</div>
<input type = "file" required = "required" id = "photo" name = "photo" />
</div>
<br />
<div class = "form-group">
<button name = "edit_room" class = "btn btn-warning form-control"><i class = "glyphicon glyphicon-edit"></i> Save Changes</button>
</div>
</form>
<?php
// require_once 'database.php';
include("database.php");
if(ISSET($_POST['edit_room'])){
$room_type = $_POST['room_type'];
$price = $_POST['price'];
$photo = addslashes(file_get_contents($_FILES['photo']['tmp_name']));
$photo_name = addslashes($_FILES['photo']['name']);
$photo_size = getimagesize($_FILES['photo']['tmp_name']);
move_uploaded_file($_FILES['photo']['tmp_name'],"photo/" . $_FILES['photo']['name']);
$db->query("UPDATE `room` SET `room_type` = '$room_type', `price` = '$price', `photo` = '$photo_name' WHERE `room_id` = '$_REQUEST[room_id]'") or die(mysqli_error());
header("location:managehotel1.php");
}
?>
</div>
</div>
</div>
</div>
<br />
<br />
</body>
<script src = "../js/jquery.js"></script>
<script src = "../js/bootstrap.js"></script>
<script type = "text/javascript">
$(document).ready(function(){
$pic = $('<img id = "image" width = "100%" height = "100%"/>');
$lbl = $('<center id = "lbl">[Photo]</center>');
$("#photo").change(function(){
$("#lbl").remove();
var files = !!this.files ? this.files : [];
if(!files.length || !window.FileReader){
$("#image").remove();
$lbl.appendTo("#preview");
}
if(/^image/.test(files[0].type)){
var reader = new FileReader();
reader.readAsDataURL(files[0]);
reader.onloadend = function(){
$pic.appendTo("#preview");
$("#image").attr("src", this.result);
}
}
});
});
</script>
</html>