I see a couple of minor things. Some are debugging things that I find helpfull, some may make a difference, and some are more just personal coding preference.
add this debug code to be removed later:
$sql = "SELECT user_id
FROM tbl_auth_user
WHERE user_id = '$userId' AND user_password = PASSWORD('$password')";
echo "sql: ".$sql."<br />\n";
I am assuming that you use phpMyAdmin or something similar. Anyway copy/paste the displayed sql statement to do a manual query to make sure the sql is doing what you expect.
Next (and this is personal preference) change
<?php
if ($errorMessage != '') {
?>
<p align="center"><strong><font color="#990000"><?php echo $errorMessage; ?></font></strong></p>
<?php
}
?>
to one of these two:
<?php
if ($errorMessage != '') {
echo "<p align=\"center\"><strong><font color=\"#990000\">$errorMessage</font></strong></p>\n";
}
?>
or
<?php
if ($errorMessage != '') {
?>
<p align="center"><strong><font color="#990000"><?=$errorMessage?></font></strong></p>
<?php
}
?>
There's no action in your form tag. You need to tell it where to go:
<form action="" method="post" name="frmLogin" id="frmLogin">
In main.php
<?php
session_start();
if (!isset($_SESSION['db_is_logged_in']) || $_SESSION['db_is_logged_in'] !== true) {
header('Location: login.php'); // not logged in, move to login page
exit;
}
?>
Make these small changes. Change the || to OR and the !== to !=
<?php
session_start();
if (!isset($_SESSION['db_is_logged_in']) OR $_SESSION['db_is_logged_in'] != true) {
header('Location: login.php'); // not logged in, move to login page
exit;
}
?>
I don't know if any of these changes will make any significant difference, but I always find it helpful to add echo statement to display values of key variables to make sure I'm getting what I think I'm getting. Once the script works, I go back and either remove or comment out all my debugging lines.