HTML
|
|
|
|
<?
/* By Christiano Anderson - anderss@zaz.com.br */
/* http://www.anderson.eti.br */
if(!isset($PHP_AUTH_USER)) {
Header("WWW-authenticate: basic realm="Login Required""); Header("HTTP/1.0 401 Unauthorized"); $title="Login screen"; ?>
<center><font face="verdana" size="2" color="#FF0000">
Username and Password are required to view this page.<br>
<br>
Contact the webmaster
<br>
<br>
</font> </center>
<? exit;
} else { mysql_pconnect("host_here","login_here","password_here") or die("Unable to connect to SQL server"); mysql_select_db("database_here") or die("Unable to select database");
$user_id=strtolower($PHP_AUTH_USER); $password=$PHP_AUTH_PW;
$query = mysql_query("select * from users where username='$user_id' and senha=password('$password')");
if(!mysql_num_rows($query)) { Header("WWW-authenticate: basic realm="Auth Required""); Header("HTTP/1.0 401 Unauthorized"); $title="Login Instructions";
?>
<center><font face="verdana" size="2" color="#FF0000">
Username and Password are required to view this page.<br>
<br>
Contact the webmaster
<br>
<br>
</font> </center>
</font> </center>
<?
exit;
}
}
?>
|
|
|
Usage Example
|
|
|
Rate This Script
|
|
|
|