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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:45:15+00:00 2026-06-10T11:45:15+00:00

I am trying to check login credentials against 2 different tables and the query

  • 0

I am trying to check login credentials against 2 different tables and the query keeps coming back saying that the user doesn’t exist. I will try to explain what I am doing…

I have a table called customers that stores customer data only. I have another table called admins that stores credentials for admins only.

I would like to have the admins be able to log in to the site using the same log in screen as the customers. Once they are logged in, the system will know that they are an admin and display the proper widgets for administrating the product data on the site.

I inserted a dummy user in the admins table and ran this query:

    $sql = mysql_query("SELECT EXISTS(
    SELECT 1 FROM `customers` WHERE `email` = 'johndeere@whatever.com' AND `password` = 'password'
    UNION
    SELECT 1 FROM `admins` WHERE `Email` = 'johndeere@whatever.com' AND `Password` = 'password'
    )");
    $result = @mysql_query($sql);
    if(!$result) {
        echo "User doesn't exist!";
    } else {
        echo "User exists!";
    }

This query is coming back saying “User doesn’t exist” when I know for a fact they are in the admins table. I’m sure that I am missing something very simple and was hoping someone could help me out with what it is.

I am still pretty new to mySQL and PHP but I am learning fast. This is, so far, the only problem that I could not fix or find an answer for. Your help is greatly appreciated. Thanks in advance.

  • 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-10T11:45:17+00:00Added an answer on June 10, 2026 at 11:45 am

    why don’t you use,

    SELECT 1 from dual where EXISTS(
        SELECT 1 FROM `customers` WHERE `email` = 'johndeere@whatever.com' AND `password` = 'password'
        UNION
        SELECT 1 FROM `admins` WHERE `Email` = 'johndeere@whatever.com' AND `Password` = 'password'
    );
    

    your query will return 0(false), 1(true), you need to check these values, if you use original query

    You can’t use !$result as it only tells weather query was legal or not., you need to retrieve the data.

    Refer this: http://www.php.net/manual/en/function.mysql-query.php

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

Sidebar

Related Questions

As part of my login procedure I'm trying to check that the user has
Trying to get into PostgreSQL. I'm drawing an function that will check credentials Here
I am trying to make a script to login into my check card balance
First, check this message which I was trying to do: Login To log on
I am trying to check if an email address already exists in a user
I'm receiving many failed login requests from spammers/bots that are trying to brute-force the
I am trying to develop my login script to give feedback to the user
I am trying to create a thread to handle a login function that is
I am trying to check if the user is logged in in facebook (and
How I can check user credentials for local computer? For example, I have this

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.