note 42602 deleted from function.header by kennyt
| From: | kennyt@php.net | Date: | Sun, 18 Jul 2004 18:03:10 +0000 |
| Subject: | note 42602 deleted from function.header by kennyt | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-73549@lists.php.net to get a copy of this message | ||
Note Submitter: alexandrebarboza@globo.com
----
My solution for login/logout in mysql.
<?
error_reporting(E_ERROR | E_PARSE);
session_start();
$link = mysql_connect("localhost",$_SERVER['PHP_AUTH_USER'] ,
$_SERVER['PHP_AUTH_PW']);
if (!$link || $_SESSION['logout']) {
unset($_SESSION['logout']);
header('WWW-Authenticate: Basic realm="MySQL"');
header('HTTP/1.0 401 Unauthorized');
echo 'Access denied.';
} else {
if ($_GET['Logout'] == "True") {
$_SESSION['logout'] = true;
echo '<a
href="'.$_SERVER['PHP_SELF'].'">Login</a>';
} else {
echo '<a
href="'.$_SERVER['PHP_SELF'].'?Logout=True">Logout</a>';
}
}
mysql_close($link);
?>