evillazydwarf
Programmer
I'm quite new to php and i;m struggling, i'm trying to write a simple login section which checks a username and a password against a database and then either redirects you to the main website (if details are correct) or back to the login page (if incorrect)
I've got a simple html form which posts to a page which processes the database query and sets up a session, giving the username as the 1 and only session variable
this is then redirected to the main page in the website, where i use the following include file:
to determine whether a session is already started or whether the user needs to log in... the problem is that even though i've just set the session variable it seems to dissappear and i get sent straight back to the login page and i have no idea why, any help would be very much appreciated
I've got a simple html form which posts to a page which processes the database query and sets up a session, giving the username as the 1 and only session variable
Code:
session_start();
$_SESSION['username'] = $username;
this is then redirected to the main page in the website, where i use the following include file:
Code:
<?php
session_start();
if(!isset($_SESSION['username']))
{
$location = "login.htm";
header("Location:$location");
}
?>
to determine whether a session is already started or whether the user needs to log in... the problem is that even though i've just set the session variable it seems to dissappear and i get sent straight back to the login page and i have no idea why, any help would be very much appreciated