-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsert.php
128 lines (106 loc) · 3.91 KB
/
insert.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
<?php include 'header.php'; ?>
<?php
$mysqli=new mysqli('localhost','root','','property');
if($mysqli->connect_error){
printf("can not connect databse %s\n",$mysqli->connect_error);
exit();
}
if(isset($_POST['submit'])){
$name=$_POST['name'];
$monthly=$_POST['monthly'];
$address=$_POST['address'];
$access=$_POST['access'];
$floor=$_POST['floor'];
$utility=$_POST['utility'];
$descrip=mysqli_real_escape_string($mysqli ,$_POST['descrip']);
$target_dir="uploads/";
$target_file= $target_dir . basename($_FILES["images"]["name"]);
$temp_file=$_FILES["images"]["name"];
move_uploaded_file($_FILES["images"]["tmp_name"], $target_file);
$query="INSERT INTO propety (name,monthly,address,access,floor,utility,descrip,images) VALUES ('$name','$monthly','$address','$access','$floor','$utility','$descrip','$temp_file')";
$insert=$mysqli->query($query);
$last_id = $mysqli->insert_id;
$c=count($_FILES['img']['name']);
if($insert){
if($c < 10){
for ($i=0; $i <$c; $i++) {
$img_name=$_FILES['img']['name'][$i];
move_uploaded_file($_FILES['img']['tmp_name'][$i] , "uploads/" .$img_name);
$query_multi="INSERT INTO details(images,proid) VALUES ('$img_name','$last_id')";
$ins=$mysqli->query($query_multi);
}
// else{
// echo "MAX LIMIT EXCEED";
// }
}
}
}
?>
<div class="container">
<form class="form-horizontal" action="" method="post" enctype="multipart/form-data">
<fieldset>
<legend>Add a Property </legend>
<div class="form-group">
<label for="inputEmail" class="col-lg-2 control-label">Name Of Property</label>
<div class="col-lg-10">
<input type="text" name="name" class="form-control" placeholder="Name Of Property">
</div>
</div>
<div class="form-group">
<label for="inputPassword" class="col-lg-2 control-label">Monthly Charge</label>
<div class="col-lg-10">
<input type="text" name="monthly" class="form-control" placeholder="Monthly Charge">
</div>
</div>
<div class="form-group">
<label for="textArea" class="col-lg-2 control-label">Address</label>
<div class="col-lg-10">
<textarea class="form-control" name="address" rows="3" id="textArea"></textarea>
</div>
</div>
<div class="form-group">
<label for="inputPassword" class="col-lg-2 control-label">Access</label>
<div class="col-lg-10">
<input type="text" name="access" class="form-control" placeholder="Access">
</div>
</div>
<div class="form-group">
<label for="inputPassword" class="col-lg-2 control-label">Floor Space</label>
<div class="col-lg-10">
<input type="text" name="floor" class="form-control" placeholder="Floor Space">
</div>
</div>
<div class="form-group">
<label for="inputPassword" class="col-lg-2 control-label">Utility</label>
<div class="col-lg-10">
<input type="text" name="utility" class="form-control" placeholder="Utility">
</div>
</div>
<div class="form-group">
<label for="textArea" class="col-lg-2 control-label">Description</label>
<div class="col-lg-10">
<textarea class="form-control" name="descrip" rows="3" id="textArea"></textarea>
</div>
</div>
<div class="form-group">
<label for="textArea" class="col-lg-2 control-label">Featured Image</label>
<div class="col-lg-10">
<input type="file" name="images">
</div>
</div>
<div class="form-group">
<label for="textArea" class="col-lg-2 control-label">Rooms Images</label>
<div class="col-lg-10">
<input type="file" name="img[]" multiple>
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<button type="reset" class="btn btn-danger">Cancel</button>
<button type="submit" name="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</fieldset>
</form>
</div>
<?php include 'footer.php' ; ?>