Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 390413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:57:44+00:00 2026-05-12T15:57:44+00:00

Here is my last login part that dosen’t seem to work here it is.

  • 0

Here is my last login part that dosen’t seem to work here it is. I think I messed up somewhere?

    // Query the database:
    $q = "SELECT user_id, first_name, user_level FROM users WHERE (email='$e' AND pass=SHA1('$p')) 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.

        // Register the values & redirect:
        $_SESSION = mysqli_fetch_array ($r, MYSQLI_ASSOC); 
        $q = "UPDATE users SET last_login = NOW() WHERE (email='$e' AND pass=SHA1('$p')) AND active IS NULL"; 
        // save the info to the database
        $r= mysqli_query( $dbc );
        mysqli_free_result($r);
        mysqli_close($dbc);

Here is the full script.

<?php
if (isset($_POST['submitted'])) {
    require_once (MYSQL);

    // Validate the email address:
    if (!empty($_POST['email'])) {
        $e = mysqli_real_escape_string ($dbc, $_POST['email']);
    } else {
        $e = FALSE;
        echo '<p class="error">You forgot to enter your email address!</p>';
    }

    // Validate the password:
    if (!empty($_POST['pass'])) {
        $p = mysqli_real_escape_string ($dbc, $_POST['pass']);
    } else {
        $p = FALSE;
        echo '<p class="error">You forgot to enter your password!</p>';
    }

    if ($e && $p) { // If everything's OK.

        // Query the database:
        $q = "SELECT user_id, first_name, user_level FROM users WHERE (email='$e' AND pass=SHA1('$p')) 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.

            // Register the values & redirect:
            $_SESSION = mysqli_fetch_array ($r, MYSQLI_ASSOC); 
            $q = "UPDATE users SET last_login = NOW() WHERE (email='$e' AND pass=SHA1('$p')) AND active IS NULL"; 
            // save the info to the database
            $r= mysqli_query( $dbc );
            mysqli_free_result($r);
            mysqli_close($dbc);

            $url = BASE_URL . 'index.php'; // Define the URL:
            ob_end_clean(); // Delete the buffer.
            header("Location: $url");
            exit(); // Quit the script.

        } else { // No match was made.
            echo '<p class="error">Either the email address and password entered do not match those on file or you have not yet activated your account.</p>';
        }

    } else { // If everything wasn't OK.
        echo '<p class="error">Please try again.</p>';
    }

    mysqli_close($dbc);

} // End of SUBMIT conditional.
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T15:57:44+00:00Added an answer on May 12, 2026 at 3:57 pm

    You are probably not even running the query,

    $q = "UPDATE users SET last_login = NOW() WHERE (email='$e' AND pass=SHA1('$p')) AND active IS NULL"; 
                            // save the info to the database
                            $r= mysqli_query( $dbc );
    

    should be

    $q = "UPDATE users SET last_login = NOW() WHERE (email='$e' AND pass=SHA1('$p')) AND active IS NULL"; 
                            // save the info to the database
                            $r= mysqli_query( $dbc ,$q);
    

    and I would advice you to check whether the update took place using affected_rows

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the working query: $sql_project_data = SELECT P.project_id, P.project_name, P.project_type, F.professor_first_name, F.professor_last_name, C.course_id
last time I asked how to populate a data structure here . Now I
I am stuck here and i spend last 2 days resolving this issue but
Here is my problem. I'd like to get the last inserted Id with a
I was wondering about the last constructor for std::string mentioned here . It says:
After my last, failed, attempt at asking a question here I'm trying a more
Hopefully the last NN question you'll get from me this weekend, but here goes
I'm using some code from here to determine when determining when the last finger
How do you get the last day of the last month in csh? Here
I need to make an application for school that includes a login and rights.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.