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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:40:49+00:00 2026-05-25T17:40:49+00:00

I have just found a pretty major vulnerability in my code while doing some

  • 0

I have just found a pretty major vulnerability in my code while doing some testing,

Basically if my username was “admin” and password was say “12345”…
and a user joined with and chose the name “Admin” and the same password “12345”
when he/she goes to login they will be in my account on the website, As you can imagine I have created quite a flaw, as this would affect every potential user on the site.

So, my question is what can I change in this statement to make it check for an EXACT match.

   WHERE login_name ='$user' AND user_password ='$pass' LIMIT 1";  

Heres the login_process.php file

    <?php
    require_once("includes/session.php");
    $connection = mysql_connect("localhost", "user", "password");
    if(!$connection)
    {
        die("Database connection failed: " . mysql_error());
    }
    $db_select = mysql_select_db("game", $connection);
    if(!$db_select)
    {
        die("Database selection failed: " . mysql_error());
    }
    $user = mysql_real_escape_string($_POST['username']);
    $pass = mysql_real_escape_string($_POST['password']);
    $pass = sha1($pass);

    // Need to make a change to the below query, as it doesn't match for case sensitivity.

    $query = "SELECT user_id, user_name, user_level FROM users WHERE login_name ='$user' AND user_password ='$pass' LIMIT 1";
    $result=mysql_query($query);
    if(mysql_num_rows($result) == 1)
    {
        $found_user = mysql_fetch_array($result);
        $_SESSION['user_id'] = $found_user['user_id'];
        $_SESSION['user_name'] = $found_user['user_name'];
        $_SESSION['user_level'] = $found_user['user_level'];
        header("Location: index.php");
    }
    else 
    {
        echo "The username or password you entered was incorrect. <br/> Please click <a href='login.php'>Here</a> to try again.";
    }
    ?>
  • 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-25T17:40:51+00:00Added an answer on May 25, 2026 at 5:40 pm

    the default collation of database is case insensitive . so the user admin and Admin or adMin are the same. While creating user check the database whether same username already exist or not.

    it seems that you are using case sensitive collation.. you can use case insensitive collation for that user table so that your query will work fine.

    or

    while creating user and checking the database for duplicate entry use LCASE function as follows

    SELECT * FROM USERS WHERE LCASE(username) = 'admin'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Found some old code, circa VS 2003. Now I have just VS 2008 (SP1)
I have just found RowSets for database querying with JDBC. They are stateless and
I have just found this great tutorial as it is something that I need.
I have just installed Eclipse 3.4 and found out that there is not a
I have just moved job and gone from VB 6 to VB.Net and found
I have an interview tomorrow morning and just found out that I will also
I am learning Java and just found that the Interface can have fields, which
I have a question that I just don't feel like I've found a satisfactory
I have made a image gallery with jQuery found here: http://sarfraznawaz2005.kodingen.com/demos/jquery/image_gallery/ I just wanted
I'm pretty new to J2ME development scene. And for that matter, have just recently

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.