-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearchFiles.php
More file actions
53 lines (45 loc) · 1.33 KB
/
Copy pathsearchFiles.php
File metadata and controls
53 lines (45 loc) · 1.33 KB
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
<html>
<body>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<div class="w3-bar w3-black">
<a href="projectLinks.html" class="w3-bar-item w3-button">Home</a>
<a href="upload1.php" class="w3-bar-item w3-button">Upload</a>
<a href="searchFiles.html" class="w3-bar-item w3-button">Search</a>
<a href="viewFile1.php" class="w3-bar-item w3-button">View</a>
</div>
<?php
$searchBy = $_POST['field'];
$searchFor = $_POST['term'];
// database name and password
$database = '';
$password = '';
$db = mysqli_connect('', $database, $password);
$record = "SELECT * FROM project WHERE $searchBy LIKE '%".$searchFor."%'";
$result = mysqli_query($db, $record);
while($myrow = mysqli_fetch_array($result))
{
if ($searchBy === "user"){
if ($myrow['user'] === $searchFor) {
echo "<br><br>File Name: <a href= ".$myrow["filename"].">".$myrow["filename"]."</a>";
echo "<br> User: ".$myrow['user'];
} else {
$r="There were no entries";
}
} elseif ($searchBy === "filename") {
if ($myrow['filename'] === $searchFor){
echo "<br><br>File Name: <a href= ".$myrow["filename"].">".$myrow["filename"]."</a>";
echo "<br> User: ".$myrow['user'];
} else {
$s="There were no entries";
}
} else {
$t="ERROR";
}
}
echo $s;
echo $r;
echo $t;
?>
</body>
</html>