Hey
I am having a small problem with my login page. It first checks if there is a session IE if logged in, if not to goes to the login page, if it is logged in then it will remain on the main page.
[code=php]
<?php session_start();
if (!isset($_SESSION[‘isLogged’])) {
header(“Location: ./../_admin/index.php?function=Login”);
exit();
} else {
include ‘./../_admin/includes/header.php’;
?>
<table align=”center” width=”996″ border=”1″ class=”content” cellpadding=”4″ cellspacing=”4″><tr><td>
<table align=”center” width=”985″ border=”0″ cellpadding=”4″ cellspacing=”4″>
<tr>
<td align=”center” valign=”top”>
<?php
if (isset($_SESSION[‘status’])) {
echo $_SESSION[‘status’];
} else {
echo ‘Welcome ‘.$_SESSION[‘username’].’ – Use the links above to navigate!’;
}
?>
</td>
</tr>
</table>
</td></tr></table>
<?php
}
if ($_GET[‘function’] == “Login”) {
$_SESSION[‘isLogged’] = ”;
include ‘./../_admin/includes/header.php’;
?>
<table align=”center” width=”996″ border=”1″ class=”content” cellpadding=”4″ cellspacing=”4″><tr><td>
<table align=”center” width=”985″ border=”0″ cellpadding=”4″ cellspacing=”4″>
<tr>
<td align=”center” valign=”top”>
<form action=”index.php?function=LoginDo” method=”post” name=”login” id=”login”>
<table width=”100%” border=”0″ align=”center” cellpadding=”5″ cellspacing=”0″>
<tr>
<td colspan=”2″><div align=”center” style=”color:#FF0000″><strong><?php echo $_SESSION[‘message’]; ?></strong></div></td>
</tr>
<tr>
<td colspan=”2″><div align=”center”><strong>Please log in:</strong></div></td>
</tr>
<tr>
<td width=”47%”><strong>Username:</strong></td>
<td width=”53%”><input name=”username” type=”text” id=”username”></td>
</tr>
<tr>
<td><strong>Password:</strong></td>
<td><input name=”password” type=”password” id=”password”></td>
</tr>
<tr>
<td colspan=”2″><div align=”center”>
<input name=”Submit” type=”submit” id=”Submit” value=”Sign In”>
<input name=”submitID” type=”hidden” id=”submitID” value=”1″><br /><br />
<a href=”index.php?function=Forgot”>Forgot Password?</a></div></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</td></tr></table>
<?php
} elseif ($_GET[‘function’] == “LoginDo”) {
if($_POST[‘submitID’] == ‘1’){
$username = mysql_real_escape_string($_POST[‘username’]);
$password = mysql_real_escape_string($_POST[‘password’]);
$_SESSION[‘message’] = NULL;
if($username == NULL) {
$_SESSION[‘message’] = ‘Please enter username.’;
header(“Location: ./../_admin/index.php?function=Login”);
exit();
}
if($_SESSION[‘message’] == NULL && $password == NULL){
$_SESSION[‘message’] = ‘Please enter password.’;
header(“Location: ./../_admin/index.php?function=Login”);
exit();
}
if($_SESSION[‘message’] == NULL)
{
$userQuery = mysql_fetch_row(mysql_query(“SELECT COUNT(*) FROM ebcs_settings WHERE `Settings_Username`=’$username’ AND `Settings_Password`=’$password'”));
if($userQuery[0] > 0){
$_SESSION[‘message’] = NULL;
$_SESSION[‘isLogged’] = ‘1’;
$_SESSION[‘username’] = $username;
setcookie(“isLogged”, ‘1’, time()+86400);
setcookie(“username”, $username, time()+86400);
header(“Location: ./../_admin/index.php”);
exit();
} else {
$_SESSION[‘message’] = ‘Invalid username and/or password!’;
header(“Location: ./../_admin/index.php?function=Login”);
exit();
}
}
} else {
header(“Location: ./../_admin/index.php?function=Login”);
exit();
}
}
?>
Thanks for any help!