<?php // since want to use $_SESSION array here, need: session_start(); ?> <!DOCTYPE html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <!-- using session variables to control a multi-state application by: Sharon Tuttle last modified: 2026-04-21 you can run this using the URL: https://nrs-projects.humboldt.edu/~st10/s26cs328/328lect13-1/try-quad.php --> <head> <title> try-quad </title> <meta charset="utf-8" /> <?php // turn on error reporting ini_set('display_errors', 1); error_reporting(E_ALL); // bring in some needed PHP functions require_once("request_name.php"); require_once("request_quest.php"); require_once("request_color.php"); require_once("show_farewell.php"); require_once("complain_and_exit.php"); require_once("build_mini_form.php"); ?> <link href="https://nrs-projects.humboldt.edu/~st10/styles/normalize.css" type="text/css" rel="stylesheet" /> </head> <body> <h1> try-quad </h1> <?php // I decide to make and use a $_SESSION key next_state // to help navigate through the states in my application // if next_state is NOT a key in $_SESSION, start at the // first state, request_name if (! array_key_exists("next_state", $_SESSION)) { request_name(); $_SESSION["next_state"] = "quest"; } // otherwise, use $_SESSION["next_state"]'s value to // to determine the next state to give the user elseif ($_SESSION["next_state"] == "quest") { request_quest(); $_SESSION["next_state"] = "color"; } elseif ($_SESSION["next_state"] == "color") { request_color(); $_SESSION["next_state"] = "farewell"; } elseif ($_SESSION["next_state"] == "farewell") { show_farewell(); session_destroy(); } // I HOPE I cannot reach this, but JUST in case... else { session_destroy(); ?> <p> <strong> YIKES! should NOT have been able to reach here! </strong> </p> <p> <a href="<?= htmlentities($_SERVER["PHP_SELF"], ENT_QUOTES) ?>"> Start over </a> </p> <?php } ?> <footer> <hr /> <p> Validate by pasting .xhtml copy's URL into<br /> <a href="https://validator.w3.org/nu"> https://validator.w3.org/nu </a> or <a href="https://html5.validator.nu/"> https://html5.validator.nu/ </a> </p> </footer> </body> </html>