<?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

    $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");
    

    Since parameter 1 is $conn your next job is to find out why $conn is not a mysqli. It would have something to do with whatever connect.php does and returns.

      Since I don't believe include returns anything, my guess is you're overwriting whatever it sets for $conn within that include file, and setting it to false or null?

        Upon further review, it could be returning something:

        Handling Returns: include returns FALSE on failure and raises a warning. Successful includes, unless overridden by the included file, return 1. It is possible to execute a return statement inside an included file in order to terminate processing in that file and return to the script which called it. Also, it's possible to return values from included files. You can take the value of the include call as you would for a normal function.

        https://www.php.net/manual/en/function.include.php

        NogDog Upon further review, it could be returning something:

        Which I have to admit I find disturbing. No doubt a holdover from "Personal Home Page" template days.

        • Mime replied to this.
          7 days later

          Weedpacket
          The homepage works just fine, but when I go to the Login page that's when all this comes up

          Mime

          Created in 1994 by Rasmus Lerdorf, the very first incarnation of PHP was a simple set of Common Gateway Interface (CGI) binaries written in the C programming language. Originally used for tracking visits to his online resume, he named the suite of scripts "Personal Home Page Tools," more frequently referenced as "PHP Tools."
          https://www.php.net/history.php

          • Mime replied to this.
            Write a Reply...