Jump to content

Members Only


dean7

Recommended Posts

Hi all, i coded a login script yesterday and got it all working, but now i only want users to view the members page if they have logged in.

 

<?php
include ("config.php");
session_start();

$username = $_SESSION['username'];

if ($username == ""){
    echo ("You Must Login");
    header ('Location: index.php');
}else{
    echo ("");
}
?>

 

But with that code its not letting them login either though they have posted the correct detials.

 

Anyone know why?

 

Thanks For Your Help.

Link to comment
https://forums.phpfreaks.com/topic/181589-members-only/
Share on other sites

Is it not redirecting?

if not:

You cant echo something and then "header redirect".

echo "Blah";

Header(loca.....);

 

Cant do it. Use a meta refresh instead.

 

There really isnt enough info to help with the "...not letting them login..." part.

I doubt that issue is a result of the script you posted.

Link to comment
https://forums.phpfreaks.com/topic/181589-members-only/#findComment-957868
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.