He has giving us the other pages we only need to do the index page. The progam is suppose to match presdents to there name. He is what I have so far
<?php
require_once "include/session.php";
$session = new Session();
if (!isset($session->valid)) {
require_once "login.php";
exit();
}
require_once "include/presidents.php";
// this is the simple list of their terms
$terms = array_keys($pres_terms);
// this is the simple list of their names with duplicates removed
$pres_names = array_unique(array_values($pres_terms));
// sort the names by last name
usort($pres_names, "byLastName");
$params = (object) $_REQUEST;
if (isset($params->guess)) {
$pres_terms = $params->$pres_term;
$terms = $params->term;
$answers = $params->answer;
$pres_names = $params->pres_name;
$choices->pres_name[$pres_name] = "selected";
$responces = $params->responce;
if ($choices == $answer) {
$responce = "you got it right";
}
else {
$responce = "You got it wrong";
}
}
else {
$pres_term = $pres_terms[rand(0, count($pres_terms))];
$answers = $pres_names;
}
// RIGHT HERE IS WHERE OTHER PHP HANDLER CODE GOES
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>U.S. President Guess Game</title>
</head>
<style type='text-css'>
.logout {
text-align:right;
padding-right: 10px;
}
</style>
<body>
<p class='logout' class='logout'><a href="validate.php?logout=1">Logout</a></p>
<p><a href=".">Start Over</a></p>
Who was US President during the term <?php echo $term ?>
<form action="?" method="post">
<input type="hidden" name="pres_term" value="<?php echo $pres_term ?>" />
<input type="hidden" name="answer" value="<?php echo $answer ?>" />
<input type="hidden" name="responce" value="<?php echo $responce ?>" />
<select name="pres_name">
<?php foreach ($pres_names as $pres_name): ?>
<option<?php echo $choices->pres_name[$pres_name] ?> >
<?php echo $pres_name?></option>
<?php endforeach ?>
</select>
<input type="submit" name="guess" value="Guess" />
</form>
<?php echo $answer?><?php echo $term?>
<h3><?php echo $responce ?></h3>
<pre>
<?php
// the developer may cheat by uncommenting this:
print_r($pres_terms);
?>
</pre>
</body>
</html>
this is what is is suppot to do
Initial activation. Generate a selection list of presidents names sorted and choose a random term:
I make the guess "Grover Cleveland" by choosing him from the selection list and pressing the button. It's wrong and so the presentation indicates that in some way:
I make a second guess "James Garfield" by again choosing him from the selection list and pressing the button. It's correct and so the presentation indicates that in some way:
I press the Start Over hyperlink. This generates an initial activation as in step 1.
<?php
require_once "include/session.php";
$session = new Session();
if (!isset($session->valid)) {
require_once "login.php";
exit();
}
require_once "include/presidents.php";
// this is the simple list of their terms
$terms = array_keys($pres_terms);
// this is the simple list of their names with duplicates removed
$pres_names = array_unique(array_values($pres_terms));
// sort the names by last name
usort($pres_names, "byLastName");
$params = (object) $_REQUEST;
if (isset($params->guess)) {
$pres_terms = $params->$pres_term;
$terms = $params->term;
$answers = $params->answer;
$pres_names = $params->pres_name;
$choices->pres_name[$pres_name] = "selected";
$responces = $params->responce;
if ($choices == $answer) {
$responce = "you got it right";
}
else {
$responce = "You got it wrong";
}
}
else {
$pres_term = $pres_terms[rand(0, count($pres_terms))];
$answers = $pres_names;
}
// RIGHT HERE IS WHERE OTHER PHP HANDLER CODE GOES
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>U.S. President Guess Game</title>
</head>
<style type='text-css'>
.logout {
text-align:right;
padding-right: 10px;
}
</style>
<body>
<p class='logout' class='logout'><a href="validate.php?logout=1">Logout</a></p>
<p><a href=".">Start Over</a></p>
Who was US President during the term <?php echo $term ?>
<form action="?" method="post">
<input type="hidden" name="pres_term" value="<?php echo $pres_term ?>" />
<input type="hidden" name="answer" value="<?php echo $answer ?>" />
<input type="hidden" name="responce" value="<?php echo $responce ?>" />
<select name="pres_name">
<?php foreach ($pres_names as $pres_name): ?>
<option<?php echo $choices->pres_name[$pres_name] ?> >
<?php echo $pres_name?></option>
<?php endforeach ?>
</select>
<input type="submit" name="guess" value="Guess" />
</form>
<?php echo $answer?><?php echo $term?>
<h3><?php echo $responce ?></h3>
<pre>
<?php
// the developer may cheat by uncommenting this:
print_r($pres_terms);
?>
</pre>
</body>
</html>
this is what is is suppot to do
Initial activation. Generate a selection list of presidents names sorted and choose a random term:
I make the guess "Grover Cleveland" by choosing him from the selection list and pressing the button. It's wrong and so the presentation indicates that in some way:
I make a second guess "James Garfield" by again choosing him from the selection list and pressing the button. It's correct and so the presentation indicates that in some way:
I press the Start Over hyperlink. This generates an initial activation as in step 1.