<?php /*----- function: request_quest purpose: expects nothing, returns nothing, but has the side-effects of trying to read the user's name from the requesting form, and saves that name for later use while also using it in a customized response and quest-form -----*/ function request_quest() { // if get here -- better be a name in $_POST! // (trim removes leading and trailing blanks // from a string... 8-) ) if ( (! array_key_exists('name', $_POST)) or (! isset($_POST['name']) ) or (trim($_POST['name']) == "") ) { complain_and_exit("name"); } // if get here -- I think I can proceed $user_name = strip_tags($_POST['name']); $_SESSION['name'] = $user_name; ?> <h2> Well, <?= $user_name ?>, WHAT is your QUEST? </h2> <form method="post" action="<?= htmlentities($_SERVER['PHP_SELF'], ENT_QUOTES) ?>"> <input type="text" name="quest" required="required" /> <input type="submit" value="submit quest" /> </form> <?php } ?>