So I have done sessions before and never had problems with them. For some reason the session variable 'login' is not being passed to the next page. Any suggestions?
[code=php]
<?php
session_start() ;
if (isset($_GET['user'])) {
include 'yyy.php';
if ($_GET['user'] == $username && $_GET['password'] == $password) {
$_SESSION['login'] = 'a';
} else {
echo 'ERROR: Username/Password combination incorrect.<br>< br>';
}
}
if (!isset($_SESSI ON['login'])) {
print '<form name="input" action="#" method="get">
Username:
<input type="text" name="user">
<br>
Password:
<input type="password" name="password" >
<input type="submit" value="Submit">
</form>
';
} elseif ($_SESSION['login'] == 'a') {
if ($_GET['page'] == 'logout') {
unset($_SESSION['login']);
include 'main.php';
} else {
$file = $_GET['page'] . ".php";
if ($file == ".php") { $file = "main.php"; }
include $file;
}
}
?>
[/code]
[code=php]
<?php
session_start() ;
if (isset($_GET['user'])) {
include 'yyy.php';
if ($_GET['user'] == $username && $_GET['password'] == $password) {
$_SESSION['login'] = 'a';
} else {
echo 'ERROR: Username/Password combination incorrect.<br>< br>';
}
}
if (!isset($_SESSI ON['login'])) {
print '<form name="input" action="#" method="get">
Username:
<input type="text" name="user">
<br>
Password:
<input type="password" name="password" >
<input type="submit" value="Submit">
</form>
';
} elseif ($_SESSION['login'] == 'a') {
if ($_GET['page'] == 'logout') {
unset($_SESSION['login']);
include 'main.php';
} else {
$file = $_GET['page'] . ".php";
if ($file == ".php") { $file = "main.php"; }
include $file;
}
}
?>
[/code]
Comment