genome Posted March 6, 2014 Share Posted March 6, 2014 <?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 list of the terms $terms = array_keys($term_presidents); // this is the list of all names (duplicates removed), sorted by last name $presidents = array_unique(array_values($term_presidents)); usort($presidents, "byLastName"); /* DO NOT MODIFY THE ABOVE LINES !!!!! */ $params = (object) $_REQUEST; print_r($params); $session->$terms = $terms; /* Remaining Php handler code goes here */ if (isset($params->guess)) { $answer = $session->answer; $term = $session->term; $presidents = $params->presidents; $wrong = $session->wrong; $old_answer = $answer; if ($answer == $old_answer) { $wrong += 1; } $session->wrong = $wrong; $session->answer = $answer; $response = "Sorry wrong guess # $wrong ."; } else { // choose a random word $term = $terms[ mt_rand( 0, count($terms)-1 ) ]; $session->$term = $term; $wrong = 0; $session->wrong = $wrong; } ?> <!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" /> <meta http-equiv="X-UA-Compatible" content="IE=edge"/> <title>Average Calculator</title> <style type="text/css"> body { padding: 20px; } #logout { position: absolute; top: 40px; right: 40px; } form { margin: 10px 0; } .spacing { letter-spacing: .5em; /* Add more style rules */ </style> </head> <body> <a id="logout" href="logout.php">Log out</a> <a id =<?php echo $president;?></a> <h2>President Guesss Game</h2> <form action="program.php" method="get"> <button type="submit" name="reset" >New Game</button> </form> <!-- Add form and presentation code --> During the term <pre> <?php echo $term?> <pre> who was the U.S President? <select name="presidents"> <?php foreach ($presidents as $value): ?> <option <?php if ($value == $params->presidents) echo "selected" ?> ><?php echo $value?></option> <?php endforeach ?> </select> <input type="submit" name="guess" value="Guess" /> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
genome Posted March 6, 2014 Author Share Posted March 6, 2014 im stomped on when i click submit, it wont do anything . ad its not posting the answer on the form either . Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted March 6, 2014 Share Posted March 6, 2014 nothing is being submitted because you don't have an opening <form ... > tag for the select menu. i'm pretty sure they still teach 'estimating' in math classes, where you estimate the magnitude of the answer you expect so that you know if the work you are doing is even in the correct 'ball-park' to produce the result you expect? the same concept applies in programming. you must have an idea what result (in this case a html form) you are trying to produce is supposed to look like so that you know the work you are doing is going to produce the result you expect. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.