-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackend-searchprop.php
215 lines (201 loc) · 7.55 KB
/
backend-searchprop.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<?php
session_start ();
$localhost = "localhost";
$name = "root";
$password ="";
$dbname ="real estate";
function customError($errno, $errstr) {
error_log("[$errno] $errstr",3,"errors.log");
}
set_error_handler("customError");
function checkcon($con){
if(!$con)
throw new Exception ("connection failed!");
}
$conn=mysqli_connect($localhost,$name,$password,$dbname);
try{
checkcon($conn);
}
catch(Exception $e){
$emesg= $e->getMessage();
trigger_error("error in connecting has been triggered ");
echo "<script>alert('$emesg')</script>";
echo '<script>window.location.href= "index.php";</script>';
}
if(!isset($_SESSION['username']))
{ echo "<script>alert('you're not logged in');</script>";
echo '<script>window.location.href= "Login.php";</script>';
}
else{
$username=$_SESSION['username'];
}
if(!isset($_SESSION['acctype']))
{ echo "<script>alert('you're not logged in');</script>";
echo '<script>window.location.href= "Login.php";</script>';
}
else{
$acctype=$_SESSION['acctype'];
}
$sql = "Select prop_type.type, deal.type, property.*
from property
join prop_type
on prop_type.id = property.type
join deal
on property.deal = deal.id
";
// Escape user inputs for security
$term = $_POST['term'];
if(!empty($term)){
// Attempt select query execution
$sql = $sql." WHERE property.propertyID LIKE '%" . $term . "%'
or property.roomnum LIKE '%" . $term . "%'
or deal.type LIKE '%" . $term . "%'
or property.location LIKE '%" . $term . "%'
or property.bednum LIKE '%" . $term . "%'
or property.minprice LIKE '%" . $term . "%'
or property.maxprice LIKE '%" . $term . "%'
or prop_type.type LIKE '%" . $term . "%' ";
}
if($result = mysqli_query($conn, $sql)){
error_log("$sql..",3,"databaseoperations.log");
if(mysqli_num_rows($result) > 0){
while($row = mysqli_fetch_array($result)){
$propID=$row['propertyID'];
$sql3="SELECT picture FROM pictures WHERE propertyID = '$propID' LIMIT 1";
if(mysqli_query($conn,$sql3)){
error_log("$sql3..",3,"databaseoperations.log");
$result3=mysqli_query($conn,$sql3);
}
else{
$errorconn= mysqli_error($conn);
trigger_error("$errorconn sql3 backendsearchprop.php");
}
?>
<section id="portfolio"class="section-bg">
<div class="col-lg-4 portfolio-item filter-app wow fadeInUp">
<div class=" portfolio-wrap">
<figure>
<?php
while($row3=mysqli_fetch_assoc($result3))
{
?>
<img src="img/<?php echo $row3['picture'];?>" class="img-fluid" alt="">
<?php
}
?>
</figure>
<div class="portfolio-info">
<?php
if($row['type']==1){
$type="Villa";
}
else if($row['type']==2){
$type="Apartment";
}
else if($row['type']==3){
$type="Duplex";
}
else{
$type="Studio";
}
?>
<h4> <?php echo $type.' in '.$row['location'];?></h4>
<div class="row">
<div class="col-lg-2 box">
<i class="fa fa-bed"> </i>
<br>
<?php echo $row['bednum'];?>
</div>
<div class="col-lg-2 box">
<i class="fa fa-s15"></i>
<br>
<?php echo $row['roomnum'];?>
</div>
<div class="col-lg-2 box">
<i class="fa fa-institution"></i>
<br>
<?php echo $row['area'].' sqft';?>
</div>
<div class="col-lg-2 box">
<i class="fa fa-money"></i>
<br>
<?php echo $row['minprice'].'$'.'<br>'.'-'.'<br>'.$row['maxprice'].'$';?>
</div>
<div class="col-lg-2 box">
<i class="glyphicon glyphicon-screenshot"></i>
<br>
<?php
if($row['deal']==1)
$deal="Rent";
else $deal="Sale";
echo $deal;
?>
</div>
<div class="col-lg-2 box">
<i class="fa fa-lock"></i>
<i class="fa fa-unlock"></i>
<br>
<?php
if($row['availability']==1)
$avl="Available";
else $avl="Sold";
?>
<?php echo $avl;?>
</div>
</div>
<div class="row">
<?php
if($_SESSION['acctype']=="1")
{
?>
<div class="col-lg-6 box">
<?php
$proprow=$row['propertyID'];
$usernameid=$_SESSION['username'];
$sql5="SELECT propertyID , buyerID FROM request WHERE propertyID='$proprow' AND buyerID='$usernameid' ";
if(mysqli_query($conn,$sql5)){
$result5=mysqli_query($conn,$sql5);
if(mysqli_num_rows($result5)>0){
?>
<i class="fa fa-gavel"> </i>
<br>
<label value='requested'>Requested</label>
<?php }
}
else{$errorconn= mysqli_error($conn);
trigger_error("$errorconn sql5 backendendsearch.php");
}
?>
</div>
<div class="col-lg-6 box">
<i class="fa fa-eye"></i>
<form action="moredetails.php" method='post' >
<input type='hidden' name='propID' value=<?php echo $row['propertyID'] ?> >
<input type='submit' value='See More' name='details' class="seemore">
</form>
</div><!--chat form-->
<?php
} ?>
</div>
</div>
</div>
</div>
</section>
<?php
}
echo"<table border=50 BORDERCOLOR=#000000 width=100%>
<tr><th> </th><th>End of search</th></tr>";
} else{
echo"<table border=50 BORDERCOLOR=#000000 width=100%>
<tr><th> </th><th>No Matches Found</th></tr>";
echo"<table border=50 BORDERCOLOR=#000000 width=100%>
<tr><th> </th><th>End of search</th></tr>";
}
} else{
$errorconn= mysqli_error($conn);
trigger_error("$errorconn sql backendsearchprop.php");
}
echo"</table>";
// close connection
mysqli_close($conn);
?>