-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_info.php
100 lines (99 loc) · 3.79 KB
/
add_info.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.</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>
<div class = "container-fluid">
<div class = "panel panel-default">
<div class = "panel-body">
<br />
<div class = "col-md-4">
<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">Standard</option>
<option value = "Superior">Superior</option>
<option value = "Super Deluxe">Super Deluxe</option>
<option value = "Jr. Suite">Jr. Suite</option>
<option value = "Executive Suite">Executive Suite</option>
</select>
</div> -->
<div class = "form-group">
<label>Place Name </label>
<input type = "text" class = "form-control" name = "pname" />
</div>
<div class = "form-group">
<label>Place Description </label>
<input type = "text" class = "form-control" name = "pdescription" />
</div>
<div class = "form-group">
<label>Package</label>
<input type = "number" class = "form-control" name = "package" />
</div>
<div class = "form-group">
<label>Photo </label>
<div id = "preview" style = "width:150px; height :150px; border:1px solid #000;">
<center id = "lbl">[Photo]</center>
</div>
<input type = "file" required = "required" id = "pi_main" name = "pi_main" />
</div>
<br />
<div class = "form-group">
<button name = "add_info" class = "btn btn-info form-control"><i class = "glyphicon glyphicon-save"></i> Saved</button>
</div>
</form>
<?php
if(ISSET($_POST['add_info'])){
$pname = $_POST['pname'];
$pdescription = $_POST['pdescription'];
$pi_main = addslashes(file_get_contents($_FILES['pi_main']['tmp_name']));
$package = $_POST['package'];
// $photo_name = addslashes($_FILES['pi_main']['pi_main']);
// $photo_size = getimagesize($_FILES['pi_main']['tmp_name']);
// move_uploaded_file($_FILES['pi_main']['tmp_name'],"images/" . $_FILES['pi_main']['name']);
$db->query("INSERT INTO `information` (pname, pdescription, pi_main, package) VALUES('$pname', '$pdescription', '$photo_name' , '$package')") 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>