Jump to content

By submit button wont work


genome

Recommended Posts

2rhkxdw.png

 

<?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" 



<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>

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.