Im writing a website, but when one goes to login it is not detecting the username/password
the code i used follows(I just started learning yesterday... so im kinda lost as to why its not working).
<?php
session_start();
$errorMessage = '';
if (isset($_POST['txtUserId']) && isset($_POST['txtPassword'])) {
$host="localhost";
$username="falconnest_forumuser";
$password="qazasdedc";
$db_name="falconnest_forum";
$tbl_name="tbl_auth_user";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$userId = $_POST['txtUserId'];
$password = $_POST['txtPassword'];
$sql = "SELECT user_id FROM $tbl_name 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) {
$_SESSION['db_is_logged_in'] = true;
header('Location: /forum/');
exit;
} else {
$errorMessage = 'Sorry, wrong user id / password';
}
}
mysql_close();
?>