Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vandan's avatar
Level 13

How To Match Password & Confirm Password In laravel ??

'password'=>bcrypt($request->get('password')),

        'confirmpassword'=>($request->get('same:password')),
0 likes
5 replies
tykus's avatar
tykus
Best Answer
Level 104

What are you trying to do with the confirmed password? It is intended to be a validation mechanism only, not persisted.

$request->validate([
    // ... other stuff
    'password' => 'required|confirmed'
]);
lostdreamer_nl's avatar

Just set it up in the request validation as 'confirmed'

https://laravel.com/docs/5.6/validation#rule-confirmed

$this->validate($request, [
    'name' => 'required|min:3|max:50',
    'email' => 'email',
    'password' => 'required|confirmed|min:6',
]);

Now the validation will check if there is a field called password_confirmation and that it has the same value as the password field

1 like
jlrdw's avatar

You realize Jeffrey has free tutorials and videos on the stuff correct. Yes some are paid but many are free.

@Bestmomo GitHub page has free complete laravel tutorial applications look it up.

tykus's avatar

The notion of password confirmation is not to save two hashed versions of the user's password in the database; instead, it is to ensure that the user knows what they have entered - by making them repeat the same password. You ensure this by validating that the password_confirmation field matches the password field - using the confirmed validation rule as both @lostdreamer_nl and I have described above.

Just use the validation and persist the hashed password whenever validation passes!

Please or to participate in this conversation.