first page - login.htm
Expand|Select|Wrap|Line Numbers
- <html>
- <head>
- <title>login</title>
- </head>
- <body>
- <form action="login.php" method="post">
- Username: <input type="text" name="uname"><br>
- Password: <input type="text" name="pass"><br>
- <input type="submit">
- </form>
- </body>
- </html>
i get a username and password from the user
then sends it into the login.php script
[PHP]
<?
$uname = $_POST['uname'];
$pass = $_POST['pass'];
if ($uname == 'dreimer' && $pass == 'id10t')
{
session_start() ;
$_SESSION['logged'] = 'yes';
//echo $_SESSION[['logged'];
header("locatio n: logged.php");
}
?>
[/PHP]
now this gets the uname and the pass from post and checks then against the username and password that i have preset. i can get into this if statement fine. i then set a session variable ['logged'] and that is equal to 'yes'. then i redirect the header to logged.php. when i un comment the line that prints the session variable the browser displays 'yes'
and the final page
[PHP]
<?
session_start() ;
if ($_SESSION['logged'] != 'yes');
{
echo 'ahah';
//echo $_SESSION['logged'] ;
//header("locatio n: login.htm");
}
?>
<head>
<title>Untitl ed Document</title>
</head>
<body>
logged in sucessfully
</body>
</html>
[/PHP]
of here i check to see if the session variable isn't yes. and the browse displays 'ahah' and when i un comment the printing of the session variable i get the same output so basicaly i can read session vars off the page where they are set but not off other pages.
i have worked on this problem for several weeks and tried using cookies to solve the problem as well but nothing seems to work
if anyone can help me please help
eric