hi all
i am having a problem with authentication scripts. I have a form for creating users, and this information is successfully posted in to the table.
when i call the form for users to login(show_login.html), on pressing the login button nothing happens, the form is loaded again with both text boxes cleared. This form is intended to post to authuser.php.
can somebody please tell me what i am doing wrong. both files are in my document root. I have included both scripts here.
please help!!!!
Thankyou
<!--show_login.html-->
<HEAD>
<TITLE>Login</TITLE>
</HEAD>
<BODY>
<H1>Login to ul dss system KABISA</H1>
<FORM method='post' ACTION='authuser.php'>
<P><STRONG>Username:</STRONG><BR>
<INPUT TYPE="text" NAME="username" SIZE=25 MAXLENGTH=25></p>
<P><STRONG>Password:</STRONG><BR>
<INPUT TYPE="password" NAME="password" SIZE=25 MAXLENGTH=25></p>
<P><INPUT TYPE="SUBMIT" NAME="submit" VALUE="login"></p>
</FORM>
</BODY>
////////////authuser.php//////////////
<?php
if ((!$username) || (!$password))
{
header("Location: http://localhost/show_login.php");
exit;
}
$dbhost="localhost";
$dbuser="root";
$dbpsswd="";
$db_name = "kimaiyo";
$table_name = "auth_users";
$connection = @mysql_pconnect($dbhost,$dbuser,$dbpsswd)
or die("Unable to connect.");
$db = mysql_select_db($db_name, $connection)
or die("Couldn't select database.");
$sql = "SELECT username, password FROM $table_name
WHERE username = \"$username\" AND password = password(\"$password\")
";
$result = mysql_query($sql)
or die ("Can't execute query.");
$num = mysql_num_rows($result);
if ($num != 0) {
$msg = "<P>you are now loged in</p>";
}else {
header("Location: http://localhost/show_login.php");
exit;
}
?>
<HEAD>
<TITLE>The ul dss system</TITLE>
</HEAD>
<BODY>
<? echo $msg; ?>
</BODY>