note 36764 added to features.http-auth
| From: | daniloplara at yahoo dot com dot br | Date: | Tue, 21 Oct 2003 17:45:13 +0000 |
| Subject: | note 36764 added to features.http-auth | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-59050@lists.php.net to get a copy of this message | ||
Assim deu certo.
--------------------------------------------------------
<?
$auth = false;
if (isset( $PHP_AUTH_USER ) && isset($PHP_AUTH_PW)) {
#------> conecta ao banco de dados mysql <----#
mysql_connect( 'hostname', 'username', 'password' )
or die ( 'Não foi possivel conectar ao servidor.' );
#-------------> seleciona a tabela <------------#
mysql_select_db( 'sua tabela' )
or die ( 'Não há nehuma tabela selecionada.' );
$sql = "SELECT * FROM users WHERE
username = '$PHP_AUTH_USER' AND
password = '$PHP_AUTH_PW'";
$exec= mysql_query( $sql )
or die ( 'Nao foi possivel executar esta sentença.' );
$num = mysql_num_rows( $exec );
if ( $num != 0 ) {
$auth = true;
}
}
if ( ! $auth ) {
header( 'WWW-Authenticate: Basic realm="Private"' );
header( 'HTTP/1.0 401 Unauthorized' );
echo 'Authorization Required.';
exit;
} else {
echo '<div aling='center'>Usuario autorizado!</P>';
}
?>
--------------------------------------------------------
----
Manual Page -- http://www.php.net/manual/en/features.http-auth.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+36764
Delete -- http://master.php.net/manage/user-notes.php?action=delete+36764&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+36764&report=yes
Search -- http://master.php.net/manage/user-notes.php