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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:52:19+00:00 2026-06-09T00:52:19+00:00

I read php.net manual about crypt() function. And here is my code: #code….. #we

  • 0

I read php.net manual about crypt() function. And here is my code:

#code.....
#we retrieve existing salt and password from database
$salt=$saltquery['salt'];
#$ex_password - existing password
$ex_password=$saltquery['pass'];
#$pass defined earlier. that's input
$password_hash=crypt($pass, '$2a$07$'.$salt.'');
if (crypt($password_hash, $ex_password)==$ex_password) {
 #everything is ok
} else {
 #username/password combination doesn't exists
 $msgText = "Oops! Check your username and password";
 $pass=NULL;
}

I still get an error ‘Oops! Check your username and password’. I check database and output from $password_hash and they match.
Maybe it’s better to code like this:

#.....
if ($password_hash==$ex_password){}
#.....
  • 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-09T00:52:21+00:00Added an answer on June 9, 2026 at 12:52 am

    You must pass the user input to the crypt function when checking passwords (see the crypt docs):

    if (crypt($user_input, $hashed_password) == $hashed_password) {
       echo "Password verified!";
    }
    

    You are currently calculating a new (different) password hash and compare it with the one that’s stored.

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

Sidebar

Related Questions

Read some texts about locking in PHP. They all, mainly, direct to http://php.net/manual/en/function.flock.php .
How do I return the comment property from exif_read_data link: http://www.php.net/manual/en/function.exif-read-data.php
So I found a function from http://php.net/manual/en/function.exec.php function execInBackground($cmd) { if (substr(php_uname(), 0, 7)
I'm just about ready to cry. I have read the php.net manual page, tried
I am new to PHP regex, and I read the http://php.net/manual/en/function.preg-match.php . but can't
I'm using this block of code (mostly copied from a PHP.net comment here -
I read http://www.php.net/manual/en/ini.core.php#ini.post-max-size . memory_limit must > post_max_size . Then if user upload a
I am learning php and read this example in this http://www.php.net/manual/en/language.types.boolean.php tutorial, I want
I recently read about http://php.net/pcntl and was woundering how good that functions works and
so according to this: http://php.net/manual/en/function.getimagesize.php If accessing the filename image is impossible, or if

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.