1
0
mirror of https://github.com/php/web-php.git synced 2026-03-31 11:42:09 +02:00
Files
archived-web-php/oreilly99/s_sqlphoto2.php3

25 lines
824 B
PHP

<?php require "header.inc"?>
<H1>SQL'izing the Photo Album Example</H1>
<h2>The SQL-enabled auth.inc file</h2>
<?example('<? function authenticate() {
Header("WWW-authenticate: basic realm=\"Photo Album\"");
Header("HTTP/1.0 401 Unauthorized");?>
In order to proceed you will need a valid username/password.
<?
exit;
}
if(!isset($PHP_AUTH_USER)) {
authenticate();
} else {
mysql_pconnect("localhost") or die("DB Unavailable");
mysql_select_db("mydb") or die("Unable to select database");
$id=strtolower($PHP_AUTH_USER);
$query = mysql_query("select * from users where id=\'$id\' and password=\'$PHP_AUTH_PW\'");
if(!mysql_num_rows($query)) {
authenticate();
}
} ?>')?>
<?php require "footer.inc"?>