sorry for the vague title, but I am baffled as to why my session_register() function is executing in this script - I'm checking $HTTP_POST_VARS and $HTTP_SESSION_VARS using the print_r() function, and in the script below, session_register() executes after two failed logins. Why?
script:
if ((!isset($name))||(!isset($password))) {
echo "You have not logged in.<p>";
echo "Please login to the database server.<P>";
include("includes/login.inc");
exit();
} else if (!$name||!$password) {
echo "You must supply both a username and a password to connect to the database:<br>";
include("includes/login.inc");
exit();
} else {
$dbconnect = @mysql_pconnect("localhost", "$name", "$password");
$dbselect = @mysql_select_db("database", $dbconnect);
//check if user can connect to server
if (!$dbconnect) {
echo ( "<p> Sorry, but the username/password combination you supplied are not valid.</p>" );
include("includes/login.inc");
exit();
} else if (!$dbselect) {
//check if user can connect to database
echo ( "<p> Sorry, but the username/password combination you supplied are not valid for the database.</p>" );
include("includes/login.inc");
exit();
} else {
//register name and password
session_register("name", "password");
}
}
login.inc:
<form action="<?=$PHP_SELF?>" method="post">
<table>
<tr>
<td>
Name: </td>
<td>
<input type=text name="name" value="<? if ($name) echo $name;?>"></td>
<tr>
<td>
Password: </td>
<td>
<input type=password name="password" value="<? if ($password) echo $password;?>"></td>
</tr>
<tr>
<td>
<input type=submit value="Login">
</td>
</tr>
</tr>
</table>
</form>