Sunda Cyber Army


* Sunda Cyber Army 2k17 *
Indonesia Defacer ~


Path : /home/dent/public_html/demo5b/gl/
File Upload :
Current File : /home/dent/public_html/demo5b/gl/edit_drillldown.php

<?php

// Check that we received the recordid
//echo $_REQUEST["recordid"];

if(empty($_REQUEST["recordid"])) {
    echo "Please go through the <a href='search_drilldown.php'>search</a> page";
    exit();
}

// Connect to the database to retreive information about this specific DVD
$host = "webdev.iyaclasses.com";
$userid = "acad276guest_db_user";
$userpw = "coffeetea21!";
$db = "acad276guest_dvd";

include '../pdloginvariables.php';

$mysql = new mysqli(
    $host,
    $userid,
    $userpw,
    $db
);

if($mysql->connect_errno) {
    echo "db connection error : " . $mysql->connect_error;
    exit();
}

// Write SQL to get information about this DVD
$sql = "SELECT * from movieView2 WHERE dvd_title_id = ". $_REQUEST["recordid"] . ";";

// Before running SQL statements, I like to print it out to make sure my SQL statement looks correct
echo $sql . "<hr>";

// Run the sql statement
$results = $mysql->query($sql);
if(!$results) {
    echo "SQL ERROR: " . $mysql->error . "<hr>";
}

// Get the result back in an associative array
$recorddata = $results->fetch_assoc();

// I like to var_dump data out to see what is inside this variable
var_dump($recorddata);

?>

<html>
<head>
    <title>Drill down: Edit page</title>
</head>
<style>
    body {
        background-color: burlywood;
        margin: 0 200px;
        text-align: center;
    }

    #container {
        padding: 30px;
        margin-top: 100px;
        background-color: olive;
        width: 300px;
        text-align: left;
        color:white;
    }

    .label {
        float:left;
        clear:both;
        width: 120px;
    }
</style>

<body>
<div id="container">
    <div style="text-align: center">Edit Movie</div>
    <hr>

<!--    When Save Movie Changes button is clicked, send all this data over to update_drilldown.php-->
    <form action="update_drilldown.php">
        <!-- Can make hidden input types to temporarily use to submit info to the next page-->
        <input type="hidden" name="recordid" value="<?php echo $recorddata['dvd_title_id']; ?>">

        <div class="label">Title:</div>

        <input type="text" name="title" value="<?php echo $recorddata['title']; ?>">


        <br style="clear:both;">

        <div class="label">Rating:</div>
        <select name="rating">
            <!-- Make the first dropdown be the rating of this specific movie -->
            <?php

            echo "<option value='" . $recorddata['rating_id'] . "'>" . $recorddata['rating'] ."</option>";

            // Then show the rest of rating options from the DB
            $sql = "SELECT * FROM ratings";

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

            if(!$results) {
                echo "SQL error: ". $mysql->error;
                exit();
            }

            while($currentrow = $results->fetch_assoc()) {
                // OPTIONAL: if you want to not repeat the genre that is pre-selected, you can use if/else statement
                // $currentrow represents one of ALL the genres in the DB
                // $recorddata represents this specific DVD
                // selected attribute makes this dropdown appear first
                if($currentrow['rating_id'] == $recorddata['rating_id']) {
                    echo "<option selected value='" . $currentrow['rating_id'] ."'>" . $currentrow['rating'] . "</option>";
                }
                else {
                    echo "<option value='" . $currentrow['rating_id'] ."'>" . $currentrow['rating'] . "</option>";
                }

            }
            ?>


        </select>
        <br style="clear:both;">


        <div class="label">Genre:</div>    <select name="genre">

            <?php

            // Show this movie's genre first
            echo "<option value='" . $recorddata['genre_id'] . "'>" . $recorddata['genre'] ."</option>";

            $sql = "SELECT * FROM genres ORDER BY genre";

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

            if(!$results) {
                echo "SQL error: ". $mysql->error;
                exit();
            }

            while($currentrow = $results->fetch_assoc()) {
                echo "<option value='" .  $currentrow['genre_id']."'>" . $currentrow['genre'] . "</option>";
            }
            ?>
        </select>

        <br style="clear:both;">


        <br style="clear:both;">
        <div style="text-align:center;">
            <input type="submit" value="Save Movie Changes" style="background-color: darkolivegreen; color: white; border: 0">
        </div>
</div>
</form>
</body>
</html>