i have this next php script which is suppose to ask for a username and password, if the username and password are currect the script should start a session ... the problem is it doesn't start a session !!!
<?
if (!isset($PHP_AUTH_USER)) {
header('WWW-Authenticate: Basic realm="Movies Admin Control"');
header('HTTP/1.0 401 Unauthorized');
exit;
}
else if (isset($PHP_AUTH_USER))
{
// If non-empty, check the database for matches
// connect to MySQL
require("connect.php");
// Formulate the query
$results = mysql_query("SELECT * FROM admin WHERE username='$PHP_AUTH_USER' and password='$PHP_AUTH_PW'")
or die(mysql_error());
// Get number of rows in $result. 0 if invalid, 1 if valid.
$num = mysql_numrows($results);
// --------IT WILL OUTPUT 'WORKS !' BUT WON'T START THE SESSION--------------------------
echo 'works';
if ($num != "0") {
session_start();
if (!$PHPSESSID) {
session_register('PHP_AUTH_USER');
session_register('php_auth_pw');
}
else if ((!$PHP_AUTH_USER) || (!$PHP_AUTH_PW)) {
session_register('PHP_AUTH_USER');
session_register('PHP_AUTH_PW');
}
}
else
{
header('WWW-Authenticate: Basic realm="Movies Admin Control"');
header('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required.';
exit;
}
}
?>
please help me ...