Please send questions to st10@humboldt.edu .
<html>

<head>
    <title> Validated data </title>
</head>

<body>
    <?php

        // return true if form's fields have valid values,
        //     and return what otherwise?

        function is_valid_form()
        {
            // did they type in a username?

            if (strlen( trim ($_POST["username"]) ) == 0)
            {
                // this will add value of the expression on the
                //     right as a new array value whose key is
                //     one more than the highest key (or 0 if
                //     none) currently in this array

                $errors[] = "Please fill in username";
            }

            // did they type in an integer number of computers?

            if (strlen( trim ($_POST["comp_quant"]) ) == 0)
            {
                $errors[] = "Please fill in number of computers";
            }
            elseif ($_POST["comp_quant"] != 
                strval( intval( $_POST["comp_quant"])))
            {
                $errors[] = "number of computers must be an integer";
            }

            return $errors;
        }

        $problems = is_valid_form();

        if ($problems != NULL)
        {
            print "<h2> Your form was incomplete: </h2>\n";
            print "<ul>\n";

            foreach ($problems as $key => $value)
            {
                print "<li> $problems[$key] \n";
            }
            print "</ul>\n";

            print <<<LINK
            Click <a href=
"http://www.humboldt.edu/~st10/f06cis180php/180php_lect04/try_validate1.html"
                  > here </a> to try again.
LINK;
        }

        else
        {
            print "Thank you for your input!<br><br>";

            print "<ul>\n";
            print "<li> Your username: " . htmlentities($_POST["username"])
                  . "\n";
            print "<li> Your favorite editor: " . $_POST["editor"] . "\n";
            print "<li> Your # of computers: " . $_POST["comp_quant"] 
                  . "\n";
            print "</ul>";
        }
    ?>

</body>
</html>