Hi everyone,

I'm embarrased to ask as I am so new at this but here goes anyway: I have been trying to create a simple secure login screen that when successfully logged into, will allow the user access to other services. I found, modified a good tutorial and all works well. But the problem arises when I login and then try to move onto a new page. The example tutorial has a link to follow and presently displays a message but I cannot for the life of me change it without causing errors such as 'parser' errors etc.

I have tried several options suggested from this forum but as I do not know what I am doing believe I have probably made a mess of it. I include the index.php code as its very short and sweet. Could somebody please possibly help me with a way forward with this.


<? ob_start(); ?>
//start the session so you would stay logged in
//always must be on top
//include config.php file
echo '<center><img src="gt-navy-logo.bmp" width="166" height="76"</center>';
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>The site</title>
<center><a href="?p=idx">Home</a> - <a href="?p=page">Access GT Intranet</a>
//if user isn't logged in lets show him the log in form
<form action='login.php' method='POST'>
Username: <input type='text' name='username'><br>
Password: <input type='password' name='password'><br>
<input name="login" type="submit" value="Submit"><br>
//$_SESSION['username'] = the current users 
//username. It will be echoed like "Hi, user!"
echo "<br><br>Hi, ".$_SESSION['username']."! ";
echo "<a href='logout.php'>Log out</a>";}
case 'page':
//you can use it like this or use include()
echo '<br><br>Log in to see this page!';}
echo '<br><br>Only user who is logged in can see this!..and you see this so this means you are logged in;]';
<? ob_flush(); ?>
Member Avatar


ensure that you have session_start() at the beginning of each page so that your $_SESSION variables are passed.

Hi ardav,

I've checked all pages concerned and they all have the session_start() parameter at the beginings of each page. I think I've managed to crack it, I used the command:

header("Location: <web address & page>);

after the 'else' condition of the script, this worked, don't ask me why or how! Maybe my original question was badly written - for that I apologise. I probably need a php course or book for dummies.

many thanks for your help