<?php /* stub version to start function show_farewell() { ?> <p> called function show_farewell </p> <?php } end of stub version */ ?> <?php /*==== function: show_farewell purpose: expects no parameters, tries to read the user's favorite color from the submitting form, and (safely) use that PLUS $_SESSION['name'] and $_SESSION['quest'] to create a personalized, quest-including, color-including farewell ASSUMES: that caller is going to destroy session after this; does not destroy session itself because less convenient to iteratively-build application (stubs THEN each function WITH running in between) otherwise. requires: build_mini_form.php by: Sharon Tuttle last modified: 2024-04-13 ====*/ function show_farewell() { // if get here, there BETTER be a submitted color! if ( (! array_key_exists("color", $_POST)) || (trim($_POST["color"]) == "")) { complain_and_exit("color"); } // if get here, they entered something for color; // will strip any tags, I don't feel like those should // be here $user_color = trim(strip_tags($_POST["color"])); // grab previously-entered user name and quest $user_name = $_SESSION["name"]; $user_quest = $_SESSION["quest"]; // (this state is the LOGICAL END of this session; // no reason to add anything more to $_SESSION, // since it is about to be destroyed) // craft a personalized farewell response including // quest and color ?> <h2> AHA, <?= $user_name ?>, <br /> lover of the gentle hue of <?= $user_color ?>, <br /> I let you pass, and wish you well on your quest for: <?= $user_quest ?> </h2> <?php build_mini_form("", "START OVER"); } ?>