CSci 115: Computing and the Internet
Home Syllabus Assignments Tests

room.php

Below is the PHP source. This link goes to the below page as it appears in the Web browser.

<?php
    session_start();

    // This sets $action to indicate which link the user clicked
    // (as with "forward" or "left"), or "start" if the user is just
    // starting out.
    if(isset($_GET["action"])) {
        $action = $_GET["action"];
    } else {
        $action = "start";
    }

    // $location and $direction specify which image to display.
    $location = 1;
    $facing = 1;

    // $enable_forward should be TRUE to indicate that the
    // "forward" text should be linked; similarly for
    // $enable_left, $enable_right, and $enable_back.
    $enable_forward = TRUE;
    $enable_left = TRUE;
    $enable_right = TRUE;
    $enable_back = FALSE;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Room 587</title>
<style>
body { background: #000000; color: #FFFFFF; }
a { color: #FFFFFF; text-decoration: none; }
td { font-style: italic; text-align: center; color: #808080; }
</style>
</head>

<body>
<center>

<h1>Room 587</h1>

<?php
    $img_src = "http://ozark.hendrix.edu/~burch/cs/115/assn/07/"
        . "room-$location-$facing.jpg";
    echo "<img src=\"$img_src\" width=\"320\" height=\"240\""
        . " style=\"border: 2px solid #5C3900\" />";
?>

<table>
<tr>
    <td></td>
    <td><?php
        if($enable_forward) {
            echo "<a href=\"room.php?action=forward\">forward</a>";
        } else {
            echo "forward";
        }
    ?></td>
    <td></td>
</tr>
<tr>
    <td><?php
        if($enable_left) {
            echo "<a href=\"room.php?action=left\">left</a>";
        } else {
            echo "left";
        }
    ?></td>
    <td><img src="http://ozark.hendrix.edu/~burch/cs/115/assn/07/compass.png"
        width="30" height="30" /></td>
    <td><?php
        if($enable_right) {
            echo "<a href=\"room.php?action=right\">right</a>";
        } else {
            echo "right";
        }
    ?></td>
</tr>
<tr>
    <td></td>
    <td><?php
        if($enable_back) {
            echo "<a href=\"room.php?action=back\">back</a>";
        } else {
            echo "back";
        }
    ?></td>
    <td></td></tr>
</table>

</center>
</body>
</html>