Jump to content


New Members
  • Posts

  • Joined

  • Last visited

idk_php's Achievements


Newbie (1/5)



  1. I am thinking of using header('Location: trynumber.php'); because that is what our assignment is all about.
  2. <?php session_start(); $_SESSION["correct_answer"] = rand(1,100); $_SESSION["guess"] = 0; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <h1>Welcome to the Great Number Game!</h1> <h2>I am thinking of a number between 1 and 100</h2> <h2>Take a guess!</h2> <form method="post" action="tryguess.php"> <input type="text" id="guess" name="guess"> <input type="submit" value="submit"> <!-- <a href="trynumber.php"><input type="submit" value="reset"></a> --> </form> </body> </html> + tryguess.php <?php session_start(); // header('Location: trynumber.php'); if (isset($_POST['guess'])) { if ($_POST['guess'] == $_SESSION['correct_answer']) { echo "correct!"; } if ($_POST['guess'] < $_SESSION['correct_answer']) { echo "too low"; } if ($_POST['guess'] > $_SESSION['correct_answer']) { echo "too high"; } } ?>
  • 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.