I have a forum page and want a simple login for user with usernames from a predefined mysql user table. I use a `login.php` form file link from the forum, a get `$_POST` username, then use a `login_handle.php` file that calls a function to connect to the DB, query the users array, and try to validate that the `$_POST` username is in the queried list array. 

The function is below, and then the call in `login_handle.php` I'm getting various errors and don't know if this is at all a good approach. I also want to start a session during the form and verification that can grab the `$_POST` username as a `$_SESSION` username and apply to subsequent forum pages. 

```
    function isUsername($username){ //Test if proper Username from array.   
            $query = "SELECT username FROM users";
            $result = mysql_query($query);  
            $usernames = mysql_fetch_assoc($result);
            $isUname = true;

            if(!in_array("username", $usernames)) {
                echo "Please enter valid user name.<br>";
                    $isUname = false;
                    } //Search for proper username in username array.

                    return $isUname;

            }
------------------handler call-----------
            $username = $_POST["username"];
            $password = $_POST["password"];

                if(isUsername($username)==true){ // Check if username is valid.

                //$Uname = $_SESSION['username'];
                //echo "Username = " . $Uname;  
                echo '<a href="../fourm.php">go to forum</a>';
                }

```