I have a login page and if error occurs in login such as wrong data inserted, it will says wrong data inserted. However my problem is that I can login but it displays blank page for rows with null value in a row instead of a menu bar.
I can login for both rows but my homepage appears as blank page for staff_id = 12 which i think it is caused by the null value in stf_superior column.
I want every user can view the content of the homepage even if their stf_superior is null.
I dont know where the main problem is since the error says :
and my home.php got no sql at all. so i assume it must be in my login_process.php because it seems like it couldnt receive the id for row = 12 (which row contains null value in stf_superior column).
Below is my Login_Process.php
<?php
require_once('include/connection.php');
require_once('include/userGlobal.php');
if($_POST['STAFF_ID']== "" ||$_POST['LOGIN_PASSWORD']=="") {
echo "<script language=\"javascript\">alert(\"Username & password required!\");
document.location.href='index.php';</script>";
}
else{
$sql="SELECT * FROM staff where staff_id='".$_POST['STAFF_ID']."' ";
//$result = mysql_query($sql, $connection) or die(mysql_error());
$result = DB_Query($sql);
//$staffRow=mysql_fetch_array($result);
$staffRow=DB_FetchRow($result);
$the_id=$staffRow["staff_id"];
$the_pass=$staffRow["staff_pass"];
$the_status=$staffRow["stfs_id"];
//$passs = base64_encode($_POST["LOGIN_PASSWORD"]);
$passs = ecdPwd($_POST["LOGIN_PASSWORD"]);
$level = $staffRow["staff_lvl"];
if(($the_id == $_POST["STAFF_ID"])&&($the_pass == $passs) ){
//success
//update last login
$sql_stfl="SELECT * FROM staff_login where staff_id='".$the_id."'";
$rs_stfl = DB_Query($sql_stfl);
if (DB_RowsReturned($rs_stfl) > 0){
//update entry
$row = DB_FetchRow($rs_stfl);
$prevLogin = $row["stfl_last_login"];
$sql_update = "UPDATE staff_login SET stfl_prev_login='{$prevLogin}' WHERE staff_id='{$the_id}'";
DB_Query($sql_update);
} else {
//create entry
$sql_insert = "INSERT INTO staff_login (staff_id) VALUES ('{$the_id}')";
DB_Query($sql_insert);
}
setcookie("id",$_POST["STAFF_ID"]);
header("Location:Home.php");
}
else{
//reject
echo "<script language=\"javascript\">alert(\"WRONG USERNAME/PASSWORD!\");
document.location.href='index.php';</script>";
header("Location:index.php");
}
}
?>
<?php ob_flush(); ?>