Ejemplo n.º 1
0
}
if (isset($_GET['submit'])) {
    echo '<br><hr>';
    $type = $_GET['type'];
    $dob = $_GET['dob'];
    if (empty($_GET['first']) && empty($_GET['last'])) {
        echo 'Error: You must enter a first or last name.';
        exit(1);
    }
    if (empty($_GET['dob'])) {
        echo 'Error: You must enter a date of birth.';
        exit(1);
    }
    $first = !empty($_GET['first']) ? append_quotes($_GET['first']) : 'NULL';
    $last = !empty($_GET['last']) ? append_quotes($_GET['last']) : 'NULL';
    $sex = !empty($_GET['sex']) ? append_quotes($_GET['sex']) : 'NULL';
    $dod = !empty($_GET['dod']) ? $_GET['dod'] : 'NULL';
    if ($dod != 'NULL') {
        if ($dob > $dod) {
            echo 'Error: A person cannot die before they are born!';
            exit(1);
        }
        $dod = convert_date($dod);
    }
    $dob = convert_date($dob);
    $db_connection = connect_db();
    $id_query = 'select max(id) from MaxPersonID';
    $rs = mysql_query($id_query);
    if (!$rs) {
        echo 'MySQL Error.';
        exit(1);
Ejemplo n.º 2
0
echo 'Name: ' . $row['name'] . '<br>';
$sex = empty($row['sex']) ? 'N/A' : $row['sex'];
echo 'Sex: ' . $sex . '<br>';
echo 'Date of birth: ' . $row['dob'] . '<br>';
$dod = empty($row['dod']) ? 'Still alive' : $row['dod'];
echo 'Date of death: ' . $dod . '<br>';
echo '<h3>Movies acted in</h3><hr>';
$query = "select * from MovieActor where aid = {$id}";
$rs = mysql_query($query);
if (!$rs) {
    echo 'MySQL Error.';
    exit(1);
}
if (mysql_num_rows($rs) == 0) {
    echo 'No results found.';
} else {
    while ($row = mysql_fetch_assoc($rs)) {
        $mid = $row['mid'];
        $movie_query = "select title from Movie where id = {$mid}";
        $mrs = mysql_query($movie_query);
        if (!$mrs) {
            echo 'MySQL Error.';
            exit(1);
        }
        $mrow = mysql_fetch_row($mrs);
        $movie_name = $mrow[0];
        echo 'Acted as ' . append_quotes(append_quotes($row['role'])) . " in <a href='showmovie.php?id={$mid}' target='content'>{$movie_name}</a><br>";
    }
}
mysql_close();
page_footer();
Ejemplo n.º 3
0
    }
    $db_connection = connect_db();
    $id_query = 'select max(id) from MaxMovieID';
    $rs = mysql_query($id_query);
    if (!$rs) {
        echo 'MySQL Error.';
        exit(1);
    }
    $id = (int) mysql_fetch_row($rs)[0];
    // echo "<br> $id $title $year $rating $company"; //debug
    $query = "insert into Movie(id, title, year, rating, company) values ({$id}, {$title}, {$year}, {$rating}, {$company})";
    $rs = mysql_query($query);
    if (!$rs) {
        echo 'MySQL Error.';
        exit(1);
    }
    $genres = $_GET['genre'];
    foreach ($genres as $genre) {
        $genre = append_quotes($genre);
        $query = "insert into MovieGenre(mid, genre) values ({$id}, {$genre})";
        $rs = mysql_query($query);
        if (!$rs) {
            echo 'MySQL Error.';
            exit(1);
        }
    }
    update_max_id();
    echo "New movie was entered successfully to the database!";
    mysql_close();
}
page_footer();
Ejemplo n.º 4
0
echo '</select><br>';
$movie_query = "select id, concat(title, ' (', year, ')') as title from Movie";
$rs = mysql_query($movie_query);
if (!$rs) {
    echo 'MySQL Error.';
    exit(1);
}
echo "Movie: <select name='movie'>";
while ($row = mysql_fetch_assoc($rs)) {
    $mid = $row['id'];
    $title = $row['title'];
    echo "<option value='{$mid}'>{$title}</option>";
}
echo '</select><br>';
echo "Role: <input type='text' name='role' maxlength='50'><br><br>";
echo "<input type='submit' name='submit' value='Add relation'></form>";
$aid = (int) $_GET['actor'];
$mid = (int) $_GET['movie'];
$role = !empty($_GET['role']) ? append_quotes($_GET['role']) : 'NULL';
if (isset($_GET['submit'])) {
    echo '<br><hr>';
    $query = "insert into MovieActor(mid, aid, role) values ({$mid}, {$aid}, {$role})";
    $rs = mysql_query($query);
    if (!$rs) {
        echo 'MySQL Error.';
        exit(1);
    }
    echo 'Relation successfully added!';
}
mysql_close();
page_footer();
Ejemplo n.º 5
0
			</select>
			<br>
	Comment: <br>
	<textarea name='comment' rows='8' cols='60' maxlength='500'></textarea><br>
	<input type='submit' name='submit' value='Add your review!'>
	<input type='hidden' value='<?php 
echo $id;
?>
' name='id'>
</form>

<?php 
if (isset($_GET['submit'])) {
    echo '<br><hr>';
    if (empty($_GET['name'])) {
        echo 'Error: You must enter a name.';
        exit(1);
    }
    $name = append_quotes($_GET['name']);
    $rating = (int) $_GET['rating'];
    $comment = !empty($_GET['comment']) ? append_quotes($_GET['comment']) : 'NULL';
    $query = "insert into Review(name, mid, rating, comment) values ({$name}, {$id}, {$rating}, {$comment})";
    $rs = mysql_query($query);
    if (!$rs) {
        echo 'MySQL Error.';
        exit(1);
    }
    echo "New review successfully added for <a href='showmovie.php?id={$id}' target='content'>{$movie_name}</a>!";
    mysql_close();
}
page_footer();