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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:37:28+00:00 2026-06-01T17:37:28+00:00

When you authenticate registered users you make request e.g. one examples i found: $user

  • 0

When you authenticate registered users you make request e.g. one examples i found:

$user = $_POST['user'];
$pw = $_POST['password'];

$sql = "SELECT user,password FROM users 
    WHERE user='$user' 
    AND password='$pw' 
    LIMIT 1";
$result = mysql_query($sql);

if (mysql_num_rows($result)){
    //we have a match!
}else{
    //no match
}

Now what would be the benefit or any point of having LIMIT 1 at the end?
And why you need to select user and password when you can just select user_id?

Would not the

SELECT user_id FROM users
WHERE user = '{$user}'
AND password = '{$pw}'

be same exact logistics but shorter code?

EDIT: thinking about this little detail made me find one more check to prevent hackers.
There should not be more than one user with same email and password so if they somehow supply instead of password 123 e.g. string ' OR password = '*' (or similar logics) this will compromise my query, having no limit would help because next step i can count

if (count($result) > 1) {
   echo "we got hacked";
else 
   <proceed...>
  • 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-01T17:37:30+00:00Added an answer on June 1, 2026 at 5:37 pm

    Most likely, you will have a unique user column, so LIMIT 1 is not necessary – you won’t have more than 1 row anyway.

    In this case, it might be a decorative element – self explaining syntax to tell a programmer that reads a code, that query is expected to return no more than one row.

    Aside from your question, I would strongly recommend to use some password encryption, for example MD5(). A tutorial that teaches you to store a plain passwords is not the best one…

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

Sidebar

Related Questions

I want to authenticate users against our AD so I understand that I need
I'm trying to authenticate to a web server from an android class with the
I'm trying to authenticate a user through the RESTful API (not Connect) but I
i want to authenticate users using firstname and lastname This is the code i
I am trying to authenticate linkedin users for my site. I am using Scribe
I trying authenticate user in Spring Security application via oAuth. I'm already received token
I have ejabberd set up using external_auth to authenticate against the user database of
Recently I read a nice tutorial How to Authenticate Users With Twitter OAuth even
I'm designing a system where users will be able to register and afterward authenticate
Is there a way I can list the users that are registered on my

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.