Hey!
Im working on a project that involves a login... the code that handles the login is shown below...
<?php
include '/usr/home/s/l/slackernet/public_html/include/functions.inc.php';
include '/usr/home/s/l/slackernet/public_html/include/db_connect.inc.php';
session_start();
if(!isset($username) && ($password)) {
output_header("Authentication Error");
echo "<CENTER><DIV CLASS=\"pagetitle\">Authentication Error</DIV></CENTER>";
echo "<DIV CLASS=\"maintext\">Please go back and provide both a username and password.</DIV>";
output_footer();
exit;
}
$result = mysql_query("SELECT ID, username FROM slacker_users WHERE username = '$username' AND password = '$password';");
if(!mysql_num_rows($result)) {
output_header("Authentication Error");
echo "<CENTER><DIV CLASS=\"pagetitle\">Authentication Error</DIV></CENTER>";
echo "<DIV CLASS=\"maintext\">Invalid username and password combination. Please go back and try again.</DIV>";
output_footer();
} else {
$r = mysql_fetch_array($result);
session_register("ID");
session_register("User");
$ID = $r[ID];
$User = $r[username];
echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=\"$redir\">";
}
?>
Right.. Iv'e been at this for 3 days and I can't understand why this is happening. When I login, I am using a valid username and password. But, im getting an error message and the session is registering. I don't understand it.
For a working example of what I mean goto:
http://www.slackernet.org/messenger/index.php
you will be asked to login use the following details..
User: Stezz
Pass: asopkjqw
Please can someone tell me why this is happening! Iv'e made many login systems this way before and I have never had any trouble. It doesn't make sense that im having all this trouble that Iv'e never had before now.
Again, Please help if you can spot what's wrong.
Thanx!
Regards, Stezz.