Sunda Cyber Army


* Sunda Cyber Army 2k17 *
Indonesia Defacer ~


Path : /home/dent/studentexams/itsang/
File Upload :
Current File : /home/dent/studentexams/itsang/results.php

<?php
//if(empty($_REQUEST['manufacturer'])) {
//echo "Please go through search page. (or redirect)";
////header('Location: srd_search.php');
//exit();
//}
//if(empty($_REQUEST['system'])) {
//    echo "Please go through search page. (or redirect)";
////header('Location: srd_search.php');
//    exit();
//}
//if(empty($_REQUEST['type'])) {
//    echo "Please go through search page. (or redirect)";
////header('Location: srd_search.php');
//    exit();
//}

$host = "webdev.iyaclasses.com";
$userid = "dent_guest";
$userpw = "Acad276_Ttrojan_Dev2Ex@m";
$db = "dent_exam";


$mysql = new mysqli($host, $userid, $userpw, $db); //existing object/behavior in PHP

if ($mysql->connect_errno) {
    echo "ERROR in database connection";
    echo $mysql->connect_error;
    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
        <?php
        echo $results->num_rows;

        ?>
    </div>

    <table>
        <tr>
            <th>Name</th>
            <th>Price</th>
            <th>Manufacturer</th>
            <th>System</th>
            <th>Type</th>
        </tr>

        <!--
        ****** SAMPLE OUTPUT ROW ******
        -->
        <tr>
            <td>
                <?php
                $sql = "SELECT manufacturer, system, type, name, price
                        FROM devices, manufacturers, systems, types 
                        WHERE devices.manufacturer_id = manufacturers.manufacturer_id
                        AND devices.system_id = systems.system_id
                        AND devices.type_id = types.type_id
                        ";
                        
                if($_REQUEST["device_name"] != "") {
                    $sql .= " AND name ='" . $_REQUEST["device_name"] . "'";
                }
                if($_REQUEST["manufacturer_id"] != "ALL") {
                    $sql .= " AND manufacturer ='" . $_REQUEST["manufacturer_id"] . "'";
                }
                if($_REQUEST["system_id"] != "ALL") {
                    $sql .= " AND system ='" . $_REQUEST["system_id"] . "'";
                }
                if($_REQUEST["type_id"] != "ALL") {
                    $sql .= " AND type ='" . $_REQUEST["type_id"] . "'";
                }
                echo $sql."<hr>";

                $results = $mysql->query($sql);

                if(!$results) { //invalid object
                    echo "ERROR: " . $mysql->error;
                    exit();
                }

                while($currentrow = $results->fetch_assoc()) {
                        echo "<td>" . $currentrow["name"] . "</td>"
                    . "<a href='details.php?recordid=".
                    $currentrow["device_id"] . "'>" .
                    "Details" .
                    "</a>" . "<tr>" . $currentrow["manufacturer"] . "</tr>" .
                       "<tr>" . $currentrow["system"] . "</tr>" .
                           "<tr>" . $currentrow["type"] . "</tr>" ;

//Unfinished: but through the while loop, the device's name, manufacturer, system, and type is echoed out.
                    }

                ?>
            </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>
</div>
</body>
</html>