Hi all,
to start, using Apache2, MySQL 4, and PHP 4 on XP Pro box.
Problem is this:
page link to "Webpage Admin" points to admin.php.
This checks if the user is logged in like so (filename is screening.php):
session_start();
$SESSION["sourcepage"] = basename($SERVER['PHP_SELF']);
if(!isset($SESSION["authenticated"]) or $SESSION["authenticated"] != "yes"):
$SESSION['error'] = "no";
header("Location: [url]http://[/url]".$SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/enter.php");
endif;
so, the user is taken to enter.php, which is a simple name/password signin form.
User signs in with correct credentials, and test.php checks the MySQL DB for username/password. The test.php file then points the user at the original destination as specified above like so:
if($passcheck == $password and $usercheck == $username and $username!= ""):
$SESSION['authenticated'] = "yes";
$SESSION['error'] = "no";
$SESSION['user'] = "$username";
header("Location: [url]http://[/url]".$SERVER['HTTP_HOST'].dirname($SERVER['PHP_SELF'])."/".$SESSION["sourcepage"]);
(else statement cut out - it just returns to enter.php).
So, instead of taking me to admin.php like it should, it drops me into the index listing of the directory. Stranger still, after fiddling with the files for a while, changing spacing, saving and reloading, it will often start working correctly.
admin.php (and all further protected pages) contains include screening.php, so that it will check whether the user is logged in.
Any ideas? Can post full code as required.
TIA
Mark