|Due at:||9:40am, Tue 25 Sep|
|Point value:||30 pts|
Hendrix's Information Technology has hired you to create a Web page to help students find which of three labs is closest to the student's current location:
Bailey Library (the main lab)
M C Reynolds (the mathematics lab)
D W Reynolds (the psychology lab)
The idea is that students will click somewhere on the campus map, and a PHP script will compute the closest lab location and report the name of the building where it is located.
The first problem you'll need to confront is how to get an
HTML file to display an image on which the user might click so
that the click coordinates are sent to the PHP script. This is
done by using the
attribute, and by placing the
<img> element inside an
<a>) element. Basically, you can
paste the following into your HTML file.
<a href="findlab.php"><img ismap="ismap" border="0" src="http://ozark.hendrix.edu/~burch/cs/115/assn/03/campus-map.png" /></a>
When the user clicks the map, the browser will then send a request to findlab.php: You'll see in the browser's location bar that in addition to sending the name findlab.php to the server, the browser also sends to the server a question mark followed by the coordinates where the user clicked. Your PHP script can retrieve these coordinates using the following PHP code (which you should not attempt to understand using what I've taught you thus far).
$x = preg_replace("/,.*/", "", $_SERVER["QUERY_STRING"]);
$y = preg_replace("/.*,/", "", $_SERVER["QUERY_STRING"]);
After determining the click coordinates using the above PHP, your script can compute the distance to each lab using the distance formula.
(We of course assume that you know how to jump over buildings and even how to walk across the grass, so the straight-line distance is an appropriate distance estimate.)
Submit to Sauron. [Instructions]