-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditinfo.php
86 lines (82 loc) · 3.21 KB
/
editinfo.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
<!-- <!DOCTYPE html>
<?php
include("database.php");
?>
<br />
<div class = "container-fluid">
<div class = "panel panel-default">
<div class = "panel-body">
<!-- <div class = "alert alert-info"></div> -->
<br />
<div class = "col-md-4">
<?php
$query = $db->query("SELECT * FROM `information` WHERE `id` = '$_REQUEST[id]'") or die(mysqli_error());
$fetch = $query->fetch_array();
?>
<form method = "POST" enctype = "multipart/form-data">
<div class = "form-group">
<label>Place Name </label>
<input type = "text" value = "<?php echo $fetch['pname']?>" class = "form-control" name = "pname" />
</div>
<div class = "form-group">
<label>Description </label>
<input type = "text" value = "<?php echo $fetch['pdescription']?>" class = "form-control" name = "pdescription" />
</div>
<div class = "form-group">
<label>Photo </label>
<div id = "preview" style = "width:auto; height :auto; border:1px solid #000;">
<img src = "photo/<?php echo $fetch['pi_main']?>" id = "pi_main" 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['editinfo'])){
$pname = $_POST['pname'];
$pdescription = $_POST['pdescription'];
$pi_main = addslashes(file_get_contents($_FILES['pi_main']['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 `information` SET `pname` = '$pname', `pdescription` = '$pdescription', `pi_main` = '$pi_main' WHERE `room_id` = '$_REQUEST[room_id]'") or die(mysqli_error());
header("location:manageinfo1.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>