<?php
session_start();
if (isset($SESSION["manager"])) {
header("location: index.php");
exit();
}
?>
<?php
//parse the log in form iif the user has filled it out and pressed "Log In"
if (isset($POST["username"])&&isset($POST["password"])) {
$manager = preg_replace('#[A-Za-z0-9]#i','', $POST["username"]); // filter everything but numbers and letters
$password = preg_replace('#[A-Za-z0-9]#i','', $POST["password"]); // filter everything but numbers and letters
// Connect to the MySQL database
$conn = include "../storescript/connect.php";
//$sql = "SELECT FROM admin WHERE username=$manager AND passowrd=$password LIMIT 1";
// $results = mysqli_query($conn, $sql);
//$sql = mysqli_query($conn, "SELECT * FROM admin WHERE username=$manager AND password=$password LIMIT 1"); // query the person
$sql = mysqli_query($conn, "SELECT * FROM admin");
echo $sql;
// ------- MAKE SURE PERSON EXISTS IN DATABASE ---------
$existCount = mysqli_num_rows($sql); // count the row nums
if ($existCount == 1) { // evaluate the count
while($row = mysqli_fetch_array($sql)){
$id = $row["id"];
}
$SESSION["id"] = $id;
$SESSION["manager"] = $manager;
$SESSION["password"] = $password;
header("location: index.php");
exit ();
} else {
echo 'that info is incorrect, try again <a href="index.php">Click Here</a>';
exit ();
}
}
?>
been trying the above code but keep getting the following errors:
Warning: mysqli_query() expects parameter 1 to be mysqli, int given in C:\xampp\htdocs\trial1\storeadmin\adminlogin.php on line 18
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\trial1\storeadmin\adminlogin.php on line 21
Kindly help