Hi everyone

Just to test myself with php to see if i could do it properly, i made a membership system, so users can sign up, log in (and go to the members area) and log out.

On my homepage i had these links - Home | Join | Log in | Members Area

I would like to make it so, when the user is logged in, the log in link changes to log out.

Also with the members area, i couldn't think of the proper way to do i, so i just put my log in script there, so when a user logs in, if they go back to the home page and click members area - it makes them sign in again.

If you need to see my script to help me please tell me and i will post it on here.


I though of this, but i dont think it will be very good as its the first script i've created on my own. I get no error messages but the page will only display the login form, no matter whether the user is logged in or not,

eg, the user logs in goes to the members area, which is automatically brought up by login_success.php then clicks home then members area, the sign in form pops up again, even though he is signed in

<?
session_start();
 
include 'db.php';
 
$sql = mysql_query("SELECT * FROM users WHERE username='$username' AND password='$password' AND userid='$userid'");
$login_check = mysql_num_rows($sql);
 
if($login_check > 0){
header("Location: login_success.php");
 
} else {
 
header("Location: login.html");
}
 
 
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.