Tuesday, December 6, 2022
Laravel 6Php

Laravel 6 change user password complete working code

laravel change user password

Hello to all, welcome to In this post, I will tell you, Laravel 6 change user password complete working code.

laravel change user password
laravel change user password

Post Working:

In this post, I am doing, login user can change his/her password and I am doing this in Laravel 6. I will share, blade, route and controller code in this post.

Here is the working code snippet and please use carefully:

1. Here is the blade template file code:

   <div class="alert alert-success">
   <p> {{session("message")}} </p>
@foreach ($errors->all() as $error)
  <div class="alert alert-danger">
  <p>{{ $error }}</p>
<form action="{{ URL::to('/change-password') }}" method="post">
  {{ csrf_field() }}
  <div class="form-group">
      <label for="image"><strong>Change Password:</strong></label>
      <input type="password" class="form-control" id="password" placeholder="New Password" name="password" required>
      <input type="password" name="objectId" value="{{ encrypt(Auth::user()->id) }}" style="display: none;">
  <button type="submit" class="btn btn-warning">Submit</button>

2. Here is the route code:


3. Here is the controller code:

use Validator;
public function changePassword(Request $request)
      $validator = Validator::make($request->all(), [

      'password' => 'required|max:255'

      if ($validator->fails()) {
      return redirect()->back()

            $reset_password = DB::table('users')->where('id',decrypt(Input::get('objectId')))->update(['password' => bcrypt(Input::get('password'))]);    
            return Redirect::to('home')->with("message","Successful!! Password has been changed");



This is it, If you have any query then please do comment below.


Thank you

the authortherichpost
Hello to all. Welcome to Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 8, Angular 9, Angular 10, Angular 11, Angular12, Angular 13, Angular 14, Angular 15, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.