What version of laravel. And the login page load just fine.
Also use the browser developer tools to help troubleshoot the issue.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
I am building the Forum app listed in the Laracasts Series (Laravel) on this site.
I can register fine, but the login section I get the error (These credentials do not match our records.) even though the (email etc) information is inside my users table in the database.
The files I am using are the standard boiler plate I get from using the (php artisan make:auth) command.
Does anyone know a solution?
I suspect from my research the password is suspect. (it is being hashed).
Thanks
What version of laravel. And the login page load just fine.
Also use the browser developer tools to help troubleshoot the issue.
version 5.2.45
Technically registering automatically logs you in. But I want to be able to log in using credentials after logging out.
If you log out, can you log back in. Or is there errors.
No. Then it says (These credentials do not match our records.) in red. It asks for the email and the password.
try echoing the username and password and see if its getting both inputs or not
Do below in your controller and see if its getting username and password same as your database (if you are using hashing then comment that part to check the password match)
echo $username;
echo $password;
die;
Is the email and password being stored in the database. Is the password properly being bcrypted.
They are both being stored in the database. The email appears correct, the password is being hashed in the database so I can't verify that they are a match.
From what I found on google one person recommended (bcrypt password) Checking all the relevant php files I don't think so, it is being hashed.
Laravel uses bcrypt.
can you post your code here ?
I'm not 100% sure this the correct code snippet. It is from (RegisterController.php)
protected function create(array $data) { return User::create([ 'name' => $data['name'], 'email' => $data['email'], 'password' => Hash::make($data['password']), ]); }
try this
protected function create(array $data) {
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
Not working yet.
I have also tried pulling in different stuff in various files, like (use App\Models\User;)
Something is wrong with your setup, the out of the box Authentication should work without modifying stuff.
@daniel1836 try doing it manual way then. Try this
use Input;
use App\User;
class RegisterController extends Controller
{
public function create() {
$username = Input::get('name');
$email= Input::get('email');
$password= Input::get('password');
$encrypted_password = bcrypt($password);
$users = new User();
$users->username = $username;
$users->email = $email;
$users->password = $encrypted_password;
$users->save()
}
}
The most likely problem is a mismatch in the number of times the password is hashed.
Its either twice when registering (thus destroying the password), or
its hashed twice when logging in so does not match the database.
This can be caused by one of the following being the case;
None of the above should be a problem when using out of the box authentication - it just works.
So, it must be something you have changed.
But first things first, you should check that your credentials are correctly being passed to the login controller.
Thanks a lot !
@Snapey Thank you! Solved my problem.
@Snapey With your explanaition, I saw that I must delete a redundant code from my User Model [method: public function setPasswordAttribute($value)].
Thanks
@Snapey please i need your assistance i have tried everything
@JPFarber which code i am to delete
@techbros You have to delete your hash password code that si duplicate like if you have set password hahsed in casts then no need to manually Hash::make($password)
If its still not jot work than please share your code.
@amitsolanki24_ please how can I delete the hash password code I saw the Hash::make($password) what should I change it too
@amitsolanki24_ this what my codes looks like on the register controller php file protected function create(array $data) { $general = gs();
$referBy = session()->get('reference');
if ($referBy) {
$referUser = User::where('username', $referBy)->first();
} else {
$referUser = null;
}
//User Create
$user = new User();
$user->email = strtolower(trim($data['email']));
$user->password = Hash::make($data['password']);
$user->username = trim($data['username']);
$user->ref_by = $referUser ? $referUser->id : 0;
$user->country_code = $data['country_code'];
$user->mobile = $data['mobile_code'] . $data['mobile'];
$user->address = [
'address' => '',
'state' => '',
'zip' => '',
'country' => isset($data['country']) ? $data['country'] : null,
'city' => ''
];
$user->status = Status::USER_ACTIVE;
$user->kv = $general->kv ? Status::UNVERIFIED : Status::VERIFIED;
$user->ev = $general->ev ? Status::UNVERIFIED : Status::VERIFIED;
$user->sv = $general->sv ? Status::UNVERIFIED : Status::VERIFIED;
$user->ts = Status::ENABLE;
$user->tv = Status::VERIFIED;
$user->save();
@techbros can you also share you user model code
@techbros You need to check if you are not hashing the password twice or more. If you hash your password into a Controller@store, then In your User Model you should not have some function where the password will be hashed again.
Please or to participate in this conversation.