and password
function bad_auth()
{
global $database;
Header( "WWW-authenticate: basic realm=\"Database ".$database. "\"");
Header( "HTTP/1.0 401 Unauthorized");
$title = "Invalid login";
echo "\n";
echo " \n";
echo " Authorization Required \n";
echo " \n";
echo " \n";
echo " I need a username and password with which to access the database.\n";
echo " \n";
echo "\n";
exit;
}
$database=$HTTP_POST_VARS[ "DATABASE"];
$hostname=$HTTP_POST_VARS[ "HOSTNAME"];
if(!$database)
{
?>
MySQL/PHP Interface
exit;
}
if(!isset($PHP_AUTH_USER)) bad_auth();
$username = $PHP_AUTH_USER;
$password = $PHP_AUTH_PW;
$dblink = @mysql_pconnect($hostname,$username,$password);
if(!$dblink) bad_auth();
?>
echo "$database@$hostname" ?>
$tableh = mysql_list_tables($database);
if(!$tableh)
{
?>
Could not read list of tables
exit;
}
$tableno = mysql_num_rows($tableh);
if(!$tableno)
{
?>
MySQL claims this database is empty!