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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:23:38+00:00 2026-06-11T16:23:38+00:00

i am currently working on my own user class with login and register functions.

  • 0

i am currently working on my own user class with login and register functions. I am doing this mainly for the learing experience. Now i am having a problem wich i am unable to resolve.
My register function looks like this:

public function createUser($username, $email, $password)
{   
    $password = trim($password);
//Generate users salt
$user_salt = $this->getRandomHash();

//Salt and Hash the password
$password = $user_salt . $password;
$password = $this->hashData($password);

//Create verification code
$code = $this->randomString();

//Commit values to database here.
$created = "INSERT INTO users (username, email, password, user_salt, is_verified, is_active, verification_code) VALUES ('".$username."','".$email."', '".$password."', '".$user_salt."', 0, 1, '".$code."')";
    $created = $this->_database->Set($created);

if($created != false){
    return true;
}

return false;
}

while hashData looks like this:

protected function hashData($data)
{
return hash_hmac('sha512', $data, $this->_siteKey);
}

and this is my login function:

$password = trim($password);
//Select users row from database base on $email
$selection = "SELECT * FROM users WHERE username='".$username."' LIMIT 1";
    $selection = $this->_database->Get($selection);

    $row = mysqli_fetch_assoc($selection);
    //Salt and hash password for checking
    $password = $row['user_salt'] . $password;
    $password = $this->hashData($password);

    $match = false;
    //Check email and password hash match database row
    if($username == $row['username'] && $password == $row['password']){
       $match = true;
    }

Now the problem is that the passwords do not match even though i am hundret percent sure im typing it correctly. I am not quite sure why it fails because i am using the same salt to hash the typed in password. Maybe i am doing something completly wrong here…If you need more code please let me know. Otherwise thanks to anyone willing to help.

  • 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-11T16:23:38+00:00Added an answer on June 11, 2026 at 4:23 pm

    Stupid mistake on my part!

    The salt column in the database was only accepting a salt with the length of 50. My generated salt was way longer..

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

Sidebar

Related Questions

I am currently working on my own implementation of a tab bar for a
I'm currently working on a simple web application where users each have their own
Possible Duplicate: Programmatically delete my own app Currently I am working on a iphone
Currently working for the first time with JSON and with little experience of jQuery.
I am currently working on my own version of membership using Entity Framework 4.0
I'm currently working on a small console application. This application is based on a
Python noob here, Currently I'm working with SQLAlchemy, and I have this: from __init__
I am currently working on a application that will be implementing user customizable widgets
I'm currently writing my own shell as a project for a class, and have
I am currently working on my own shoutboxes using PHP, MYSQL and Jquery. When

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.