Php user logon code (cookie, database ). Below we will talk about two types of user logon methods. one is to use window verification and database tutorial password verification to achieve login. The latter is to use cookies to record user information for login, the following describes two methods for user logon. one is to use window verification and database tutorial password verification to log on. The other is to use cookies to record user information, if you need it, try it.
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, pstutorial wd FROM user WHERE username = '$ _ SERVER [PHP_AUTH_USER]' AND pswd = MD5 ('$ _ SERVER [PHP_AUTH_PW]')";
$ Result = mysql_query ($ query );
// If nothing was found, reprompt the user for the login www.zhutiai.com information.
If (mysql_num_rows ($ result) = 0 ){
Authenticate_user ();
}
}
?>
Use cookie to log on
Enter Password