PHP login script isnt working, passes variables back to page then does nothing
<p>I'm learning PHP and am having issues getting the following code to work properly. Basically the login page displays correctly, and without errors and the variables appear to be assigned correctly, but upon page reload I just get the same login form, it appears the data has either not been passed and is therefore not being acted upon.</p>

<p>I've looked at the code over and over again and even tried a different method (produced same result!) so it'd be lovely if someone helpful could spend a minute and point me in the right direction.</p>

<p>One thing that might be an issue is my server is running 5.3.9 and the book I'm working from is PHP5 so maybe some of the function I'm calling have been deprecated. Which would be a pain...</p>

<pre><code>    &lt;?php 
include_once "common_db.inc";
$register_script = "register.php";

if (!isset ($userid)) {
    login_form();
    exit;
} else {
    session_start();
    session_register ("userid", "userpassword");
    $username = auth_user ($_POST['userid'], $_POST['userpassword']);

    if (!$username) {
        $PHP_SELF = $_SERVER['PHP_SELF'];
        session_unregister ("userid");
        session_unregister ("userpassword");
        echo "Failed to authorize. " .
                "Enter a valid DX number and password." . 
                "Click the link below to try again.&lt;br&gt;\n";
        echo "&lt;a href=\"$PHP_SELF\"&gt;login&lt;/a&gt;&lt;br&gt;";
        echo "Click the following link to register&lt;br&gt;\n";
        echo "&lt;a href=\"$register_script\"&gt;Register&lt;/a&gt;";
        exit;
    } else {
        echo "Welcome, $username!";
    }
}

function login_form() 
    {
        global $PHP_SELF;
?&gt;

&lt;form method="post" action="&lt;?php echo "$PHP_SELF"; ?&gt;"&gt;
    &lt;div align="center"&gt;&lt;center&gt;
        &lt;h3&gt;Please login to use the page you requested&lt;/h3&gt;
        &lt;table width="200" cellpadding="5"&gt;
            &lt;tr&gt;
            &lt;th width="18%" align="right" nowrap&gt;id&lt;/th&gt;
            &lt;td width="82%" nowrap&gt;
                &lt;input type="text" name="userid" /&gt;
            &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
            &lt;th width="18%" align="right" nowrap&gt;password&lt;/th&gt;
            &lt;td width="82%" nowrap&gt;
                &lt;input type="password" name="userpassword" /&gt;
            &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
            &lt;td colspan="2" width="100%" nowrap&gt;
                &lt;input type="submit" value="login" name="Submit" /&gt;
            &lt;/td&gt;
            &lt;/tr&gt;
            &lt;/table&gt;
            &lt;/center&gt;
            &lt;/div&gt;
&lt;/form&gt;

&lt;?php
    }
    function auth_user($userid, $userpassword)
    {
        global $dbname, $user_tablename;
        $link_id = db_connect($dbname);
        $query = "SELECT DXNumber FROM $user_tablename WHERE DXNumber = '$userid'
                                  AND userpassword = password ('$userpassword')";
        $result = mysql_query ($query);

        if (!mysql_num_rows($result)){
            return 0;
        }else{
            $query_data = mysql_fetch_row($results);
            return $query_data[0];
        }
    }
?&gt;
</code></pre>
