Hi,
I'm creating a member area on a website using php and mysql, i've pretty much got it fiqured out besides one detail. What script do i need to put on the actual member page to make sure the user is logged in (so as it can't be accessed by typing the address in), and doing this with sessions. The script from the login page if everything else is successful is:
$username = $_POST['user'];
$password = $_POST['pass'];
$query = "SELECT * FROM login where user = '$username' or pass = password('$password')";
$execute = mysql_query($query);
$countrow = mysql_num_rows($execute);
if ($countrow == 1){
//
$_SESSION['user'] = $username;
$sid = session_id();
//
// Redirect
$url = "members.php?sid=$sid";
//
echo "<meta http-equiv=\"refresh\" content=\"5;URL=$url\">";
echo "You will be redirected to the members section in 5 sections";
And the script that i've got so far on the members page is:
<?php
session_start();
if(!empty($_SESSION['user'])){
$username = $_SESSION['user'];
echo "You are logged in, welcome $username";
};
?>
But even if i log in with the correct username and password nothing displays still. I'm just stuck on this last bit of code so if anyone could help me out it'd be greatly appreciated.
Many Thanks
Casey