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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:36:59+00:00 2026-05-23T07:36:59+00:00

I’m having this login system, where I’ve just (finally) got hash 256 added. Earlier

  • 0

I’m having this login system, where I’ve just (finally) got hash 256 added. Earlier today I had a very long thread with @KingCrunch and some others, who helped me a lot. Thanks a lot again.

But what I wan’t to do now, is that I wanna have the $salt to be unique by using:

$salt = uniqid(mt_rand());  $salt = uniqid(mt_rand());  
                            $password = hash('sha256', $salt.$_POST['password']);

Upon creating a new member, this is set, and added to database under row called “salt”.

Now, when I try to login, with the created credentials it won’t let me.

$salt = $row['salt'];
$password = hash('sha256', $salt.$_POST['password']);
$username = mysql_real_escape_string($_POST['username']);
$sql= "SELECT * FROM members WHERE username='$username' and password='$password'";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);

This is my login_ac.php, where I got $salt to be a row['salt']. I don’t think this ever would be successful because I haven’t told which column in row salt it has to pick.

So my question is: How do I get this to work? Do have to create another query or something like that?

I need $salt to be a pick from row['salt'] because I want salt to be unique.

  • 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-23T07:37:00+00:00Added an answer on May 23, 2026 at 7:37 am

    Unlike my answer in the other question I would retrieve the whole row of the user here and compare the hashes within php (to remember: I suggested to compare it within the sql query in the other question).

    $username = mysql_real_escape_string($_POST['username']);
    $sql= "SELECT * FROM members WHERE username='$username'";
    $result=mysql_query($sql);
    $row=mysql_fetch_array($result);
    

    This will retrieve the row of the user. If the username does not exists within your database mysql_num_rows($result) will return 0 (as usual). However, you can then recreate the hash and compare it against the one saved within the database

    if (hash('sha256', $row['salt'] . $_POST['password']) === $row['password']) {
      // fine
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.