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

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

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

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 2758

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Latest Questions

Author
  • 61k
Author
Asked: November 26, 20242024-11-26T08:23:08+00:00 2024-11-26T08:23:08+00:00

Change Password in Laravel 9

  • 61k

I am going to explain here, how you can change the password in laravel 9.

I have installed the laravel with Laravel Authentication and going to explain about changing password of logged in user.

Step 1 – Change Password Page:

Create a route for change password

Route::get('/change-password', [AppHttpControllersHomeController::class, 'changePassword'])->name('change-password'); 
Enter fullscreen mode Exit fullscreen mode

Cerate changePassword function in HomeController

public function changePassword() {    return view('change-password'); } 
Enter fullscreen mode Exit fullscreen mode

Create change-password.blade.php view file in resources/views

@extends('layouts.app')  @section('content')     <div class="container">         <div class="row justify-content-center">             <div class="col-md-8">                 <div class="card">                     <div class="card-header">{{ __('Chnage Password') }}</div>                      <form action="{{ route('update-password') }}" method="POST">                         @csrf                         <div class="card-body">                             @if (session('status'))                                 <div class="alert alert-success" role="alert">                                     {{ session('status') }}                                 </div>                             @elseif (session('error'))                                 <div class="alert alert-danger" role="alert">                                     {{ session('error') }}                                 </div>                             @endif                              <div class="mb-3">                                 <label for="oldPasswordInput" class="form-label">Old Password</label>                                 <input name="old_password" type="password" class="form-control @error('old_password') is-invalid @enderror" id="oldPasswordInput"                                     placeholder="Old Password">                                 @error('old_password')                                     <span class="text-danger">{{ $message }}</span>                                 @enderror                             </div>                             <div class="mb-3">                                 <label for="newPasswordInput" class="form-label">New Password</label>                                 <input name="new_password" type="password" class="form-control @error('new_password') is-invalid @enderror" id="newPasswordInput"                                     placeholder="New Password">                                 @error('new_password')                                     <span class="text-danger">{{ $message }}</span>                                 @enderror                             </div>                             <div class="mb-3">                                 <label for="confirmNewPasswordInput" class="form-label">Confirm New Password</label>                                 <input name="new_password_confirmation" type="password" class="form-control" id="confirmNewPasswordInput"                                     placeholder="Confirm New Password">                             </div>                          </div>                          <div class="card-footer">                             <button class="btn btn-success">Submit</button>                         </div>                      </form>                 </div>             </div>         </div>     </div> @endsection  
Enter fullscreen mode Exit fullscreen mode

The Output Will look like.

Change Password

Step 2 – Handle the Form Submit.

Create a POST route in routes/web.php file

Route::post('/change-password', [AppHttpControllersHomeController::class, 'updatePassword'])->name('update-password'); 
Enter fullscreen mode Exit fullscreen mode

Create updatePassword function in app/Http/Controllers/HomeController.

public function updatePassword(Request $request) {         # Validation         $request->validate([             'old_password' => 'required',             'new_password' => 'required|confirmed',         ]);           #Match The Old Password         if(!Hash::check($request->old_password, auth()->user()->password)){             return back()->with("error", "Old Password Doesn't match!");         }           #Update the new Password         User::whereId(auth()->user()->id)->update([             'password' => Hash::make($request->new_password)         ]);          return back()->with("status", "Password changed successfully!"); } 
Enter fullscreen mode Exit fullscreen mode

the final output will look like.

Change Password

The Complete Video Tutorial is below in the video.

If you face any issue while implementing, please comment your query.

Thank You for Reading

Reach Out To me.
Twitter
Instagram
TechToolIndia YouTube Channel

beginnerslaraveltutorialwebdev
  • 0 0 Answers
  • 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

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 0
  • Best Answers 0
  • Users 2k
  • Popular
  • Answers
  • Author

    ES6 - A beginners guide - Template Literals

    • 0 Answers
  • Author

    Understanding Higher Order Functions in JavaScript.

    • 0 Answers
  • Author

    Build a custom video chat app with Daily and Vue.js

    • 0 Answers

Top Members

Samantha Carter

Samantha Carter

  • 0 Questions
  • 20 Points
Begginer
Ella Lewis

Ella Lewis

  • 0 Questions
  • 20 Points
Begginer
Isaac Anderson

Isaac Anderson

  • 0 Questions
  • 20 Points
Begginer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

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.