I have the following code and using echo’s I have chased the information down the page and still when it gets to used header location in a successful login it doesnt go there.
<?php
include "config.php";
error_reporting(E_ALL);
ini_set('display_errors','On');
//Sanitize the POST values
$username = $_POST["username"];
$password = $_POST["password"];
//Input Validations
if($username == '') {
$errmsg_arr[] = 'Username missing';
$errflag = true;
}
if($password == '') {
$errmsg_arr[] = 'Password missing';
$errflag = true;
}
//Create query
//var_dump("SELECT * FROM moduleUsers WHERE username=".$username." AND password=".$password."");
$qry="SELECT * FROM moduleUsers WHERE username=".$username." AND password=".$password.";
$result=mysqli_query($link,$qry) or die(mysqli_error());
//Check whether the query was successful or not
if($result) {
if(mysqli_num_rows($result) > 0) {
//Login Successful
session_regenerate_id();
$member = mysqli_fetch_assoc($result);
$_SESSION['SESS_MEMBER_ID_2'] = $member['module_ID'];
$_SESSION['SESS_FIRST_NAME_2'] = $member['first_Name'];
$_SESSION['SESS_LAST_NAME_2'] = $member['last_Name'];
session_write_close();
header("location: /user_Admin/modules.php");
exit();
}else {
//Login failed
$errmsg_arr[] = 'your log in details are incorrect';
$errflag = true;
if($errflag) {
$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
session_write_close();
header("location: index.php");
exit();
}
}
}else {
die("Query failed");
}
?>
When I use var_dump to check on things as I have commented out above, I then get this error.
mysqli_error() expects exactly 1 parameter, 0 given in /home/ukequine/public_html/login_exec.php on line 39
Which is
$result=mysqli_query($link,$qry) or die(mysqli_error());
But like I said when I use var_dump it out puts the details fine
“SELECT * FROM moduleUsers WHERE username=x AND password=y”