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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:15:53+00:00 2026-05-12T19:15:53+00:00

I want a form where user can change password. I am able to encrypt

  • 0

I want a form where user can change password. I am able to encrypt a password, however when it is selected from the database(the original password say ‘test’) it does not recognise it.

This is when the password has been encrypted in db. i am checking to see if the typed password in form matches the one in the db:

SELECT * from table where password = md5('$typed_password')

This is how it is encrypted:

UPDATE table set field = md5('$typed_password' )

How can my select work so that when a user types it in the form the original one is recognied?

  • 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-12T19:15:53+00:00Added an answer on May 12, 2026 at 7:15 pm

    firstly: MD5 is a cryptographic hash function, not necessarily an encryption method. A hash is designed to only be performed in one direction, and cannot be reversed. (this is a good thing)

    MD5 is however cryptographically broken (not considered secure anymore); you should use another hash function (preferable Bcrypt-hash or at least SHA256)

    Looking at the code, I can see several things wrong:

    1. your password is not salted
    2. I really hope that $typed_password is properly sanitized or you are in for SQL-injection.
    3. You try to select all users from the table with the same password.

    The easiest (and probably best) way of doing passwords is by using a standard library: the Portable PHP password hashing framework and make sure you use the CRYPT_BLOWFISH algorithm.

    require('PasswordHash.php');
    
    $pwdHasher = new PasswordHash(8, FALSE);
    
    // $hash is what you would store in your database
    $hash = $pwdHasher->HashPassword( $password );
    
    // $hash would be the $hash stored in your database for this user
    $checked = $pwdHasher->CheckPassword($password, $hash);
    if ($checked) {
        echo 'password correct';
    } else {
        echo 'wrong credentials';
    }
    

    the store/check/update queries should be bound to the user’s Id:

    // Insert query
    $query = "INSERT INTO users VALUES({$userId}, '{$username}', '{$hash}')";
    
    // Select query
    $query = "SELECT hash FROM users WHERE userId = {$userId}";
    
    // Update query
    $query = "UPDATE users SET hash = '{$hash}' WHERE userId = {$userId}";
    

    And then, you should use parametrised queries instead of directly passing the variable values into the query.

    I realise this is a lot of info at once, but it is vital learn this if you do not want your script to be hackable by almost every programmer out there.

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

Sidebar

Related Questions

I have the following form. How can I check the password from the user
I want to prevent the user from maximizing the Windows Form to full screen
I want to close a System.Windows.Forms.Form if the user clicks anywhere outside it. I've
I want to move the form title, icon and close, and help buttons from
I want to reverse engineer (import into diagram form) the database definition dump of
I want a simple filter form, and a table below it. When the user
I want to make a .NET Form as a TopMost Form for another external
I want to add a drupal form to the top of a view. The
Short version: I want to trigger the Form_Load() event without making the form visible.
I want to loop over the elements of an HTML form, and store the

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.