I am just getting into sessions, and I have a problem where my login page, just tells me I have an illegitimate user and it keeps asking me to login endlessly. I don't really know what I did wrong, and I am getting kind of frustrated by my lack of understanding as to what is going on. Heres what I have so far:
Thats the simple login page, here's the login script:PHP Code:<?php
$title="JuniorSailing.com » Programs » Bucktown » Admin » Login";
include("$DOCUMENT_ROOT/includes/header.php");
?>
<font class="main_header">Bucktown Administration</font><br>
<font class="standard">Please Login</font><br><br>
<form action="/programs/bucktown/admin/login.php" method="post">
<table cellpadding="3" cellspacing="0" border="0">
<tr>
<td valign="middle" align="left">Username:</td>
<td valign="middle" align="left"><input type="text" name="username"></td>
</tr>
<tr>
<td valign="middle" align="left">Password:</td>
<td valign="middle" align="left"><input type="password" name="password"></td>
</tr>
<tr>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"><input type="submit" value="Login"> <input type="reset" value="Reset"></td>
</tr>
</table>
</form>
<?php
include("$DOCUMENT_ROOT/includes/footer.php");
?>
This page in theory should authorize the person if there is a matching row, or take them back to the little login page.PHP Code:<?php
include("$DOCUMENT_ROOT/includes/global.php");
dbconnect("bucktown");
// check login and password
// connect and execute query
$result = safe_query("SELECT id, name, password from admin WHERE name ='".$username."' AND password = '".$password."'");
if (mysql_num_rows($result) == 1)
{
// initiate a session
session_start();
// register the user's ID
session_register("SESSION_UID");
list($id, $username, $password) = mysql_fetch_row($result);
$SESSION_UID = $id;
// redirect to main page
header("Location:/programs/bucktown/admin/trailer_admin.php");
}
else
// login/pass check failed
{
// redirect to error page
header("Location:/programs/bucktown/admin/index.php");
exit;
}
?>
Then on the top of every page I want authenticated I have this:
Any ideas where I went wrong? I looked in the php manual, but it didn't really help me, it just listed the functions. Where can I find a good tutorial on this? Sitepoint doesn't have very much at all.PHP Code:// check to ensure valid session, else redirect
session_start();
if (!session_is_registered("SESSION_UID"))
{
header("Location:/programs/bucktown/admin/index.php");
exit;
}







Bookmarks