Jump to content
Larry Ullman's Book Forums

Chapter 18 - Login - Code not retu


Recommended Posts

This part of the login code does not seem to be working. I know the information is in the database and the activation field says NULL. I believe that the browser  - Firefox on a Mac - is accepting cookies. I have tried this with several users and they all have the same password. I am getting the error message that indicates that the Email and Password does not match those on file. I am set up to use PHP 7.

        // Query the database:
        $q = "SELECT user_id, first_name, user_level, pass FROM users WHERE email='$e' AND active IS NULL";
        $r = mysqli_query($dbc, $q) or trigger_error("Query: $q\n<br>MySQL Error: " . mysqli_error($dbc));
        if (@mysqli_num_rows($r) == 1) { // A match was made.
            // Fetch the values:
            list($user_id, $first_name, $user_level, $pass) = mysqli_fetch_array($r, MYSQLI_NUM);
            mysqli_free_result($r);

 

 

Link to comment
Share on other sites

Where does the code sit that actually prevents someone from logging in if they are not set to accept cookies? I would like to remove that and see if that is the differece?

I have been using your code for years and have older sites with the login.inc.php coding in the includes folder. They always worked. i guess I could go back to that but I would like to use the most updated coding available.

Link to comment
Share on other sites

You should debug the query itself to start. See if the query is returning exactly one row or not. If not, then you need to debug it backwards to see if the problem is:

  • The value of $e in the PHP script
  • The value of email in the database
  • If active has a null value in the database (not an empty value)

 

Link to comment
Share on other sites

  • 4 weeks later...
 Share

×
×
  • Create New...