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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:49:09+00:00 2026-06-18T07:49:09+00:00

Using Tuts Plus Hashing Tutorial it is constantly returning false when checking the hash

  • 0

Using Tuts Plus Hashing Tutorial it is constantly returning false when checking the hash value. The password has definitely not been entered incorrectly ‘111111’. I’ve done an IF statement to echo what it returns and it comes out as ‘False’.

The PDO query for Inserting and Selecting the information are both working correctly.

My sign up form:

$pass_hash = PassHash::hash($_POST['pwd']); 

$q = "INSERT INTO Users(password) VALUES (:password);";

$query = $db->prepare($q);

$query->bindParam(":password",$pass_hash);

$results = $query->execute();
$user_id = $db->lastInsertID();

My Log in form:

<?php
require ("include/PassHash.php");  

if(isset($_POST['login'])){
$email = $_POST['email'];
$password = $_POST['password'];

$query = $db->prepare('SELECT * FROM Users WHERE email = :email');
$query->bindParam(":email",$email);
$results = $query->execute();

$total = $query->rowCount();
$row = $query->fetch();

// Returns more than 0 rows (Email found) and checks hash.
if($total>0 && PassHash::check_password($row['password'], $_POST['password'])){     
    // Correct credentials.
    $_SESSION['user_id'] = $row['id'];
    $_SESSION['user_email'] = $email;
    session_set_cookie_params(24*60*60);
    ob_start();
    header('Location: /index.php?p=user_account', true);
    exit();
    ob_end_flush();
} else {
    // Incorrect password / email.
}
}
?>

PassHash.php

<?php
class PassHash {
// blowfish
private static $algo = '$2a';
// cost parameter
private static $cost = '$10';
// mainly for internal use
public static function unique_salt() {
    return substr(sha1(mt_rand()),0,22);
}
// this will be used to generate a hash
public static function hash($password) {
    return crypt($password,
        self::$algo .
        self::$cost .
        '$' . self::unique_salt());
}
// this will be used to compare a password against a hash
public static function check_password($hash, $password) {
    $full_salt = substr($hash, 0, 29);
    $new_hash = crypt($password, $full_salt);
    return ($hash == $new_hash);
}
}
?>

I’ve printed the password and email after the form has been submitted and both are showing, so it isn’t an input error.

  • 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-18T07:49:10+00:00Added an answer on June 18, 2026 at 7:49 am

    Increasing the VARCHAR(45) to VARCHAR(255) for the password field resolved the problem.

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

Sidebar

Related Questions

I am using this tutorial: http://mobile.tutsplus.com/tutorials/android/android-sdk-creating-a-rotating-dialer/ Which gives me a rotating dialer based on
Using getDefinitionByName I am consistently getting the error saying it is not defined (as
The following code is from a tutorial ( http://net.tutsplus.com/php/creating-a-php5-framework-part-1/ ), not mine. I have
I've been using this tutorial to build a page where we can reorder and
I'm using this tutorial: http://net.tutsplus.com/tutorials/html-css-techniques/how-to-create-a-drop-down-nav-menu-with-html5-css3-and-jquery/ This is my site: http://billcaffery.dnsd.me I'm trying to get
I'm using a slightly augmented virtual keyboard from this tutorial: http://net.tutsplus.com/tutorials/javascript-ajax/creating-a-keyboard-with-css-and-jquery/ The Jquery: $(function(){
I am using Jcrop with a preview pane as seen in the tutorial here
I followed the HTML5 Websocket tutorial of the website below: http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/ It worked well,
I'm using Stellar.js jQuery plugin to create a parallax scroll affect, but I'm not
I have been working off a tutorial on Net Tuts to create a contact

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.