* Sunda Cyber Army 2k17 *
Indonesia Defacer ~
<?php
$mysql = new mysqli (
"webdev.iyaclasses.com",
"dent_guest",
"Acad276_Ttrojan_Dev2Ex@m",
"dent_exam"
);
if($mysql->connect_errno) {
echo "db connection error : " . $mysql->connect_error;
exit();
}
if(empty(trim($_REQUEST['name']))) {
echo "You must enter a device name.";
exit();
}
if(empty(trim($_REQUEST['manufacturer']))) {
echo "You must choose a manufacturer.";
exit();
}
if(empty(trim($_REQUEST['system']))) {
echo "You must choose a system.";
exit();
}
if(empty(trim($_REQUEST['type']))) {
echo "You must choose a type.";
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Acad276 Practical Exam: Results</title>
<style>
.container {
width: 600px;
margin: auto;
}
h1 {
margin: auto;
text-align: center;
background-color: #900;
color: #FC0;
height: 60px;
line-height: 60px;
}
.num-results {
margin: 20px 10px;
}
table {
margin: auto;
margin-bottom: 20px;
width: 80%;
border-collapse: collapse;
}
th, td {
border: 1px solid #900;
border-collapse: collapse;
padding: 10px;
text-align: center;
}
img {
width: 100px;
}
.nav-link{
margin: 10px 0px;
font-size: 14px;
}
</style>
</head>
<body>
<div class="container">
<h1>Mobile Device Database: Search Results</h1>
<div class="nav-link">
<a href="search.php"><< Back to Search Page</a>
</div>
<!-- <div class="num-results">-->
<!-- Your search returned-->
<!---->
<!-- results.-->
<!-- </div>-->
<!---->
<!-- <table>-->
<!-- <tr>-->
<!-- <th>Name</th>-->
<!-- <th>Price</th>-->
<!-- <th>Manufacturer</th>-->
<!-- <th>System</th>-->
<!-- <th>Type</th>-->
<!-- </tr>-->
<!---->
<!---->
<!-- ****** SAMPLE OUTPUT ROW ******-->
<!---->
<!-- <tr>-->
<!-- <td><a href="details.php?id=10">Pixel</a></td>-->
<!-- <td>549.00</td>-->
<!-- <td>Google</td>-->
<!-- <td>Android</td>-->
<!-- <td>Smartphone</td>-->
<!-- </tr>-->
<!-- <tr>-->
<!-- <td><a href="details.php?id=11">Pixel 2</a></td>-->
<!-- <td>649.00</td>-->
<!-- <td>Google</td>-->
<!-- <td>Android</td>-->
<!-- <td>Smartphone</td>-->
<!-- </tr>-->
<!-- <tr>-->
<!-- <td><a href="details.php?id=12">Pixelbook</a></td>-->
<!-- <td>999.00</td>-->
<!-- <td>Google</td>-->
<!-- <td>Android</td>-->
<!-- <td>Laptop</td>-->
<!-- </tr>-->
<!-- </table>-->
<?php
$sql = "SELECT * FROM devices WHERE 1=1 ";
$sql = "SELECT * from devices";
// Agh! This is not working. I think it has something to do with the fact that I am trying to pull data
// from the lookup tables, while the main table only had IDs. I didn't have enough time to go back and fix
// this, but I know that it would include using something like the following. The below would allow me to
// pull the info from the lookup tables.
// $deviceresults = $mysql->query($sql);
// while ($currentrow = $deviceresults->fetch_assoc()) {
// echo "<option value='" . $currentrow["device_id"] . "'";
// if ($recorddata["device_id"] == $currentrow["device_id"]) {
// echo " selected='1'";
// }
// echo ">";
// echo $currentrow["class"] .
// "</option>";
// }
$results = $mysql->query($sql);
if($_REQUEST["name"] != ""){
$sql .= " AND name= '" . $_REQUEST["name"] . "'";
} else {
$sql .= " AND name like '%'";
}
if($_REQUEST["manufacturer"] != ""){
$sql .= " AND manufacturer='" . $_REQUEST["manufacturer"] . "'";
} else {
$sql .= " AND manufacturer like '%'";
}
if($_REQUEST["system"] != ""){
$sql .= " AND system='" . $_REQUEST["system"] . "'";
} else {
$sql .= " AND system like '%'";
}
if($_REQUEST["type"] != ""){
$sql .= " AND type='" . $_REQUEST["type"] . "'";
} else {
$sql .= " AND type like '%'";
}
echo $sql;
echo "your search returned " . $results->num_rows . " results<br>";
while($currentrow = $results->fetch_assoc()){
echo "<a href='details.php?id=" . $currentrow["device_id"] . "'>" . $currentrow["name"] . "</a>" .
$currentrow["price"] . $currentrow["manufacturer"] . $currentrow["system"] . $currentrow["type"] ."<br>";
};
?>
</div>
</body>
</html>