Below we want to talk about two kinds of user login methods one is to use the window authentication and database tutorial password Authentication to achieve login, the latter is the use of cookie logging user information to log in, the need for friends can try.
function Authenticate_user () {
Header (' Www-authenticate:basic realm= ' Secret Stash ');
Header ("http/1.0 401 Unauthorized");
Exit
}
if (! isset ($_server[' Php_auth_user ')) {
Authenticate_user ();
} else {
MySQL tutorial _pconnect ("localhost", "authenticator", "secret") or Die ("Can ' t connect to Database server!");
mysql_select_db ("Java2s") or Die ("Can ' t select Authentication database!");
$query = "Select Username, PS Tutorial wd from user WHERE username= ' $_server[php_auth_user] ' and PSWD=MD5 (' $_SERVER[PHP_AUTH_PW] ')";
$result = mysql_query ($query);
If Nothing is found, reprompt the user for the login www.zhutiai.com information.
if (mysql_num_rows ($result) = = 0) {
Authenticate_user ();
}
}
?>
Using the cookie Login method
<title>Enter Password</title>