Please send questions to st10@humboldt.edu .
<?php
    session_start();
?>
<html>
<head>
    <title> try_trio.php </title>
</head>

<body>
<?php
    if ($_SESSION['next_page'] == "farewell")
    {
        show_farewell();
    }
    elseif ($_SESSION['next_page'] == "color")
    {
        request_color();
    }
    elseif ($_SESSION['next_page'] == "quest")
    {
        request_quest();
    }
    else
    {
        request_name();
    }

    // ask for user's name

    function request_name()
    {
        print <<<PAGE_NAME
            <h2> WHAT is your NAME? </h2> 
                 <form method="post" action="$_SERVER[PHP_SELF]">
                     <input type="text" name="name">
                     <input type="submit" value="Submit it">
                 </form>
PAGE_NAME;
        $_SESSION['next_page'] = "quest";
    }

    // read user's name from form, and use that name in asking for
    //     his/her quest

    function request_quest()
    {
        // if get here -- $_POST['name'] must be set, right?

        $name = $_POST['name'];

        $_SESSION['name'] = $name;

        print <<<PAGE_QUEST
            <h2> Well, $name, WHAT is your quest? </h2>
                 <form method="post" action="$_SERVER[PHP_SELF]">
                     <input type="text" name="quest">
                     <input type="submit" value="Submit it">
                 </form>
PAGE_QUEST;
        $_SESSION['next_page'] = "color";
    }        

    // read user's quest from form, and use name from earlier and
    //     new quest in asking for his/her favorite color

    function request_color()
    {
        // if get here -- $_POST['quest'] must be set, right?

        $name = $_SESSION['name'];
        $quest = $_POST['quest'];

        $_SESSION['quest'] = $quest;

        print <<<PAGE_COLOR
            <h2> AHA - $name, your quest: $quest <br>
                 is NOBLE indeed! <br><br>
                 BUT - WHAT is your FAVORITE COLOR? </h2>
                 <form method="post" action="$_SERVER[PHP_SELF]">
                     <input type="text" name="color">
                     <input type="submit" value="Submit it">
                 </form>
PAGE_COLOR;
        $_SESSION['next_page'] = "farewell";
    }        

    // read user's color from form, and use name and quest from earlier and
    //     new color in bidding this user farewell.

    function show_farewell()
    {
        // if get here -- $_POST['color'] must be set, right?

        $name = $_SESSION['name'];
        $quest = $_SESSION['quest'];
        $color = $_POST['color'];

        print <<<PAGE_FAREWELL
            <h2> AHA - $name, lover of the gentle hue of $color, <br>
                 I let you pass, and wish you WELL on your quest: $quest <br>
                 <br>
                 <form method="post" action="$_SERVER[PHP_SELF]">
                     <input type="submit" value="Return to Beginning">
                 </form>
PAGE_FAREWELL;
        unset($_SESSION['next_page']);
    }        
?>
</body>

</html>