<?php /* stub version to start function request_color() { ?> <p> called function request_color </p> <?php } end of stub version */ ?> <?php /*===== function: request_color purpose: expects no parameters, and tries to read the user's quest from the requesting form, and (safely) use that PLUS $_SESSION['name'] to make a personalized, quest-including request for a favorite color * ALSO saves that quest in $_SESSION for future-application use requires: build_mini_form.php by: Sharon Tuttle last modified: 2024-04-13 =====*/ function request_color() { // if get here, BETTER be a quest! complain and exit if not if ( (! array_key_exists("quest", $_POST)) || (trim($_POST["quest"]) == "")) { complain_and_exit("quest"); } // if get here, there's a quest! I decide just making // any possibly-executable characters display-only // should hopefully be safe-enough $user_quest = trim(htmlspecialchars($_POST["quest"])); // ...and save the entered quest for future states $_SESSION["quest"] = $user_quest; // also grab previously-entered user name $user_name = $_SESSION["name"]; // craft personalized response including the quest // and a request for a favorite color ?> <h2> AHA, <?= $user_name ?>, <br /> your quest: <?= $user_quest ?> <br /> is NOBLE, indeed! </h2> <h2> BUT - WHAT is your FAVORITE COLOR? </h2> <?php build_mini_form("color", "Submit it"); } ?>