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

  • Home
  • SEARCH
  • 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 8388371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:27:36+00:00 2026-06-09T18:27:36+00:00

while ($stmt->fetch()) { if ($teacherusername == $dbTeacherUsername && $teacherpassword == $dbTeacherPassword) { if ($dbActive

  • 0
while ($stmt->fetch()) {
    if ($teacherusername == $dbTeacherUsername && $teacherpassword == $dbTeacherPassword) {
        if ($dbActive == 1) {
            $loggedIn = true;
        } else if ($dbActive == 0) {
            $loggedIn = false;
            echo "You Must Activate Your Account from Email to Login";
        }
    }
}

if ($loggedIn == false && $_POST) {
    echo "The Username or Password that you Entered is not Valid. Try Entering it Again";
}

In the code above, I have a problem displaying a message and I cannot seem to figure out what I am doing wrong. If the user enters in either the wrong password or username, then it displays the message

"The Username or Password that you Entered is not Valid. Try Entering it Again".

This is fine, but if the $dbActive = 0, it should only display the message

You Must Activate Your Account from Email to Login.

But instead it is displaying both messages when this happens so it instead displays

You Must Activate Your Account from Email to LoginThe Username or Password that you Entered is not Valid. Try Entering it Again.

I know why this is happening, but I cannot seem to figure it out. How can I stop it from getting both messages to be displayed if $dbActive = 0?

  • 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-06-09T18:27:38+00:00Added an answer on June 9, 2026 at 6:27 pm

    Your code explains everything pretty clearly:

    while($stmt->fetch()) {
        if ($teacherusername == $dbTeacherUsername && $teacherpassword == $dbTeacherPassword) {
            if ($dbActive == 1){
                $loggedIn = true;
            } else if ($dbActive == 0) {
    
    
                $loggedIn = false;  
    
    /****************************
     *
     * at this point, $loggedIn == false.
     *
     ****************************/
    
    
                echo "You Must Activate Your Account from Email to Login";
            }
        }
    }
    
    /****************************
     *
     * at this point, $loggedIn == false.
     *
     * since $loggedIn == false and $_POST is truthy, your if statement will get entered.
     *
     ****************************/
    
    if ($loggedIn == false && $_POST) {
        echo "The Username or Password that you Entered is not Valid. Try Entering it Again";
    }
    

    So how do we fix this? Easy! We add another variable declaring whether or not the user is active.

    $active = true;
    
    .
    .
    .
    
    if ($dbActive == 0) {
        $loggedIn = false;
        $active = false;
        echo "You Must Activate Your Account from Email to Login";
    }
    
    .
    .
    .
    
    if (!$loggedIn && $active && isset($_POST['formInputName']) {
        echo "The Username or Password that you Entered is not Valid. Try Entering it Again";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using while($stmt->fetch()) to loop though the results I get from a MySQL Query,
Is it true that in the following file, INT is taken literally, while ID
While debugging and keep pressing F5, if the source code does not exist, eclipse
While trying to build the mysql2 gem with ruby 1.9.2-p320 on Fedora 16, I
While deveoping a site (using Forms authentication and InProc sessionstate) a frequently run into
While developing an application using gwt in ecliplse crashed. Now the server is running
while looking at some code I stumbled onto: throw /*-->*/new std::exception (//... and I
While attempting to debug a job submission script, I ended up narrowing down the
While playing with standard library i've found a strange difference between python2 and python3.
While refactoring my code base I found a piece of code which I'd like

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.