Please help! I have this login script that USED to work, but I just checked it after being away for a while and it isn't protecting my page anymore. There is one page that is supposed to be password-protected. I found this script that worked wonderfully...until now. I don't know whether something was changed on the server, since it's hosted outside.
LOGIN.PHP
<?
// Login & Session example by sde
// login.php
// start session
session_start();
// convert username and password from POST or SESSION
if($POST["username"])
{
$username=$POST["username"];
$password=$POST["password"];
}
elseif($SESSION["username"])
{
$username=$SESSION["username"];
$password=$SESSION["password"];
}
// start and register session variables
session_register("username");
session_register("password");
// connect to database
include("connect.php");
// query for a user/pass match
$result=mysql_query("select * from test where username='" . $username . "' and password='" . $password . "'");
$fetch_em = mysql_fetch_array($result);
// retrieve number of rows resulted
$num=mysql_num_rows($result);
// print login form and exit if failed.
if($num < 1){
session_destroy();
?>
<html><head>
FORM THAT SUBMITS TO PROTECTED PAGE
<?
exit;
}
?>
PROTECTED PAGE
<?
include("login.php");
?>
<HTML>
.......
Can anyone see why it is not working anymore?? I echo'd out the $username and $password variables, but they're blank (as should be). When I echo'd the $num, it returned a value of 1. How is this possible?
Thanks in advanced!
Geogal