forked from lite-david/BITStrade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
58 lines (48 loc) · 1.3 KB
/
search.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
<?php
session_start();
$output='';
if(isset($_GET['submit']))
{
function validate($a)
{
$a=trim($a);
$a=strip_tags($a);
$a=mysql_real_escape_string($a);
return $a;
}
$search=validate($_GET['search']);
if($search)
{
mysql_connect("127.0.0.1","root","") or die("Could not connect");
mysql_select_db("bitstrade");
$search= preg_replace("#[^0-9a-z]#i","","$search");
$query= mysql_query("SELECT * FROM sell WHERE nick LIKE '%$search%' OR product LIKE '%$search%'");
$count= mysql_num_rows($query);
if($count == 0)
{
echo "sorry nothing matched your search term!";
}
else
{
while($l=mysql_fetch_array($query))
{
$nick=htmlspecialchars($l['nick']);
$product=htmlspecialchars($l['product']);
$hostel=htmlspecialchars($l['hostel']);
$details=htmlspecialchars($l['details']);
$number=htmlspecialchars($l['contact']);
$name=htmlspecialchars($l['name']);
$price=htmlspecialchars($l['price']);
$output.='<div>nick: '.$nick.'<br> product: '.$product.'<br>details: '.$details.'<br>price: '.$price.'<br> contact: '.$number.'<br>hostel: '.$hostel.'</div><br><br>';
}
}
}
else
{
header("location:index.php?notify=Enter a valid search term");
}
}
?>
<?php
print("$output");
?>