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 7999257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:27:11+00:00 2026-06-04T15:27:11+00:00

I am trying to make a login script where for database connection I am

  • 0

I am trying to make a login script where for database connection I am using PDO MYSQL. Here is my code:

$query = "SELECT uid,uname  from user where email_address='abc@gmail.com' AND password='".md5('abcacb')."'";
    try {
        $dbh = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME,DB_USER,DB_PASS);
        $stmt = $dbh->query($query);
        $result = $stmt->fetch(PDO::FETCH_ASSOC);
        if(!$result)
            $status = FALSE;
        else
            $status = TRUE;
        $dbh = null;
    }
    catch(PDOException $e){
        echo $e->getMessage();
    }
    print $status;

When email_address & password both are correct $status is printing 1. But if email_address or password mismatch from the database value it’s not printing anything for $status. I assume that at least it should print 0. But I am not getting where I am wrong?

  • 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-04T15:27:12+00:00Added an answer on June 4, 2026 at 3:27 pm

    When email_address & password both are correct $status is printing 1.
    But if email_address or password is mismatch from database value it’s
    not printing any thing for $status

    since you are sotring the boolean values in $status variable. boolean values have it’s own behavior in PHP.

    boolean value true will always print `1`
    boolean value false will print nothing.
    

    try this

    echo true;
    //prints 1
    
    echo false;
    //prints nothing
    

    if you want 0 to be printed, then you can do it like this.

    $status = ($result == true) ? 1 : 0; 
    

    above code is the ternary operator if you not aware. which is same as

    if($result)
        $status = 1;
    else
        $status = 0;
    

    while using conditional statement, 1 will always be treated as boolean true and 0 as false.

    i hope this answer your question.

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

Sidebar

Related Questions

I'm trying to make an auto login script and I'm stuck on the submit
I am trying to make a script to login into my check card balance
I'm trying to make a login page using html, ajax & ASP.NET.The data is
I'm trying to make a simple login script that will check the inputted username
I'm trying to make a login and logout script for a page but for
I'm currently writing a PHP login script and trying to make it as secure
Yo. I'm trying to make a simple login system in PHP and my problem
I am trying to make a forum. I already have the login and registration
I am trying to make a FTP script in Python3.2 that connects to a
I am trying to make an application using AppleScript which can remind to check

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.