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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:58:54+00:00 2026-05-26T01:58:54+00:00

Right now I am developing an application that will allow online registration. For development,

  • 0

Right now I am developing an application that will allow online registration. For development, the password check just checks a MySQL row to make sure the value matches the value in the input field.

This code checks to see that the row exists:

$res = mysql_query("SELECT * FROM `users` WHERE `username` = '".$username."' AND `password` = '".$password."'");
                    $num = mysql_num_rows($res);
                    //check if there was not a match
                    if($num == 0){
                        //if not display error message
                        echo "<center>The <b>Password</b> you supplied does not match the one for that username!</center>";

I’m confused about implementing a salt system. How would I alter this script to check for the encrypted password? I haven’t found a great tutorial that explains this in detail.

  • 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-26T01:58:55+00:00Added an answer on May 26, 2026 at 1:58 am

    A salt is a set of characters added to the beginning or end of the password before encryption and unencryption to make it harder to run a brute force attack.

    Your first create the salt which is just a random fixed series of characters and then prepend it to the password before hashing it. You should also escape your data before putting it into the query to prevent MySQL injection attacks.

    Do this when entering the pass into the database

    $username = mysql_real_escape_string($_POST['username']);
    $password = mysql_real_escape_string($_POST['pass']);
    $pass_hash = md5($SALT.$password);
    mysql_query(*query to insert $username and $pass_hash into db*)
    

    To check if the password is correct

    $username = mysql_real_escape_string($_POST['username']);
    $password = mysql_real_escape_string($_POST['pass']);
    $res = mysql_query(*query to extract $pass_hash from db where username==$username)
    //get the password from the $res and put it in a var
    if(md5($SALT.$pass_hash_from_db) == $password){*correct pass*} else {*invalid login*}
    

    Set $SALT to some large random static string such as $SALT=”WEHGFHAWEOIfjo;cewrxq#$%”;

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

Sidebar

Related Questions

Right now I'm developing the prototype of a web application that aggregates large number
I am just a beginner in i-phone development and right now i am developing
I'm writing a client and server application. Right now I've just been developing it
I am right now developing a dead simple application using backbonejs mvc javascript library.Just
I'm developing a site right now that I've been working on for more than
So I'm developing and iPhone game right now and everything has been working just
I am developing an application that will be running behind the scenes in Windows
right now I am developing an application and it has some set of images
I am developing a chat application. But Right now chatting is possible with only
I'm developing a Java webapp using Spring, Spring Security, Tomcat and MySQL. Right now

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.