The following login script is not working, i am unable to trace the problem, please anybody help me...
<?php
include ("template/login.tpl.htm");
session_start();
if (isset($_POST['userid']) && isset($_POST['userpassword'])) {
include 'library/config.php';
include 'library/opendb.php';
$userId = $_POST['userid'];
$password = $_POST['userpassword'];
// check if the user id and password combination exist in database
$sql = "SELECT user_id,user_password
FROM tbl_auth_user
WHERE user_id = '$userId' AND user_password = PASSWORD('$password')";
$result = mysql_query($sql) or die('Query failed. ' . mysql_error());
if (mysql_num_rows($result)==1) {
// the user id and password match,
// set the session
$_SESSION['db_is_logged_in'] = true;
$_SESSION['userid']= $userId;
// after login we move to the main page
header('Location: index.php');
exit;
} else {
echo "Sorry, wrong user id / password";
echo "$sql";
}
include 'library/closedb.php';
}else {
echo "please supply your id and password";
}
?>
thanks in advance..