some kind of log in error
Posted: Wed May 16, 2007 2:09 pm
ok, this is weird, because it works on one page and not on another, maybe there's something wrong.
i have this login script
but when it gets to the header it doesnt go. it shows up all the sessions, i wanted to make sure the query was good, and it is, it correctly shows all the sessions up, but wont go to the header, anyone see why?
i have this login script
Code: Select all
<?php
ob_start();
require('config.php');
echo "<center>";
//Write the login form out
echo "<form method=post action=login.php?action=check><table><tr><td><font size=2>Username:</font></td><td><input type=text name=username></td></tr><tr><td><font size=2>Password:</font></td><td><input type=password name=password></td></tr><tr><td></td><td><input type=submit value=Login></td></tr></table></form>";
//check the input
if($_GET['action'] == 'check')
{
//find the user
$result = mysql_query("SELECT * FROM user WHERE username='{$_POST['username']}'") or die(mysql_error());
$row = mysql_fetch_array( $result ); //set $row to result
if($row['username'] == "")
{
echo error();
}
else
{
//$enc = md5($_POST['Pword']);
$enc = $_POST['password'];
if($row['password'] == $enc)
{
$_SESSION['username'] = $_POST['username'];
$_SESSION['lp'] = 'pl';
$_SESSION['password'] = $enc;
$_SESSION['id'] = $row['id'];
echo "<center><font color=CCCCCC><b>Welcome " . $_SESSION['username'] . " ID# " . $_SESSION['id'] . " Password " . $_SESSION['password'] . "!</b></font>";
header( "Location: staff.php" );
exit;
}
else
{
echo error();
}
}
}
function error()
{
echo "<b>The username/password is incorrect</b>";
}
?>