yeah, here's the login script:
<?php
session_start();
header("Cache-control: private");
if(isset($_SERVER['HTTP_REFERER']) && stristr($_SERVER['HTTP_REFERER'], '?') !=== FALSE){
$redirect = preg_replace('/\?(.*)/','',$_SERVER['HTTP_REFERER']); //Remove query strings
}
else $redirect = "/index.php";
if(!isset($_POST['user']) && !isset($_SESSION['user'])) header("location: /index.php");
else{
if($_SESSION['user']){
header("location: $redirect";
}
else{
// Get the posted username and password
$user = strtolower($_POST['user']);
$pass = $_POST['pass'];
// Include the flat-file
$file = file("users.php") or die("Problem getting the user details flat-file [users.php]");
// Get the size of file
$totalLines = sizeof($file);
// Get the users details line by line
$line = 0;
$match = 0;
do{
// Check the line isn't a comment
if("//" != substr($file[$line], 0, 2)){
// Break our records up
@list($username, $password, $permission, $email, $url, $dob, $location, $joined) = explode("<del>", $file[$line]);
// Check the username and passwords match
if((strtolower($user) == strtolower($username)) && (md5($pass) == $password)) $match = 1;
else $match = 0;
}
// Exit loop if match found
if($match == 1) break;
// Increment line count
$line++;
} while($line < $totalLines);
// Include the file or send them back
if($match == 1){
$_SESSION["user"] = $user;
$_SESSION["pass"] = $pass;
$_SESSION["permission"] = $permission;
$_SESSION["email"] = $email;
$_SESSION["url"] = $url;
$_SESSION["dob"] = $dob;
$_SESSION["location"] = $location;
$_SESSION["joined"] = $joined;
// Refresh page
header("location: $redirect");
}
else header("location: /index.php?fail=1");
}
}
?>
and here's snippets of a random page that is to use sessions:
<?php //TOP OF PAGE
session_start();
header("Cache-control: private");
// ........SKIP SOME.........
if(isset($_SESSION['user'])){
echo "<br />";
print (ucfirst(strtolower($_SESSION['user'])));
echo " | ";
/* if ($_SESSION['location'] !== ""){
print $_SESSION['location'];
echo " | ";
} */
// CURRENTLY NOT USING ABOVE COMMENTED CODE
echo "<a href='mailto:"; print $_SESSION['email'];
echo "'>"; print $_SESSION['email'];
echo "</a> | ";
if ($_SESSION["permission"] > "1") echo "Admin";
elseif ($_SESSION["permission"] == "1") echo "Moderator";
elseif ($_SESSION["permission"] == "0") echo "User";
echo "<img alt='' width='20px;' height='15' src='/images/main_spacer.jpg' />";
echo "<strong>";
echo "<a class='heading' href='/members/logout.php'>Logout</a>";
echo "</strong>";
}
?>
The above script just returns nothing and if I turn on all errors, it gives an undefined index error, which, as I was told earlier, means that the array value I'm asking for isn't there
--Thanks