Jump to content
Larry Ullman's Book Forums

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



Link to post
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 post
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 post
Share on other sites
  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...