HELP! I am not understanding sessions at all, and I can't find a decent tutorial anywhere on the web.
Here is the problem, I have a login screen with the code:
if ($user && $pass)
{
if (($user==$userdatabase) && ($pass==$passdatabase))
{
$_SESSION['user'] = $user;
}
else
{
echo ">Wrong Info!";
}
}
and I then redirect like so:
if (isset($_SESSION['user'])) {
?><meta http-equiv="REFRESH" content="0;url=http://chwilio.garcad.com/members.php"><?
}
which doesn't seem to work. Neither does the other file members.php, it as if I haven't logged in. Here's the code for that file:
<?
session_start();
$websiteTitle = "MY WEB";
//$user = &$_SESSION['user'];
?>
<html>
<head>
<?
echo "<title>$websiteTitle</title>";
?>
<LINK REL=StyleSheet HREF="css/chwilio.css" TYPE="text/css" MEDIA=screen>
</head>
<body>
<?
if (isset($_SESSION['user'])) {
echo '<p>Logged in | <a href="logout.php">logout</a></p>';
echo "<p>Helo $user! </p>";
}else{
?>
<p>You are not logged in, <a href="login2.php">click here</a> to log in</p>
<?
}
?>
</body>
</html>
Where am I going wrong?
A computer always does what you tell it to, but rarely does what you want it to.....
Here is the problem, I have a login screen with the code:
if ($user && $pass)
{
if (($user==$userdatabase) && ($pass==$passdatabase))
{
$_SESSION['user'] = $user;
}
else
{
echo ">Wrong Info!";
}
}
and I then redirect like so:
if (isset($_SESSION['user'])) {
?><meta http-equiv="REFRESH" content="0;url=http://chwilio.garcad.com/members.php"><?
}
which doesn't seem to work. Neither does the other file members.php, it as if I haven't logged in. Here's the code for that file:
<?
session_start();
$websiteTitle = "MY WEB";
//$user = &$_SESSION['user'];
?>
<html>
<head>
<?
echo "<title>$websiteTitle</title>";
?>
<LINK REL=StyleSheet HREF="css/chwilio.css" TYPE="text/css" MEDIA=screen>
</head>
<body>
<?
if (isset($_SESSION['user'])) {
echo '<p>Logged in | <a href="logout.php">logout</a></p>';
echo "<p>Helo $user! </p>";
}else{
?>
<p>You are not logged in, <a href="login2.php">click here</a> to log in</p>
<?
}
?>
</body>
</html>
Where am I going wrong?
A computer always does what you tell it to, but rarely does what you want it to.....