Click here to Skip to main content
15,915,711 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can i check the new password and confirm password are matches or not using If condition.All the process are working correctly but matching new and confirm password how can i do???

What I have tried:

public function TeacherUpdatePassword(Request $request)
{
   $curr_password = $request->curr_password;
   $new_password  = $request->new_password;
   $confm_password  = $request->confm_password;

   if(!Hash::check($curr_password,Auth::user()->password)){
   echo 'The specified password does not match';
   } 
  else{
  $request->user()->fill(['password' => Hash::make($new_password)])->save();
  echo 'Updated Successfully'; 
  }

 }
Posted
Updated 18-Aug-17 22:01pm
v2

1 solution

If I understand correctly, you want to verify that new_password and confm_password are equal. You can do this:
PHP
if ($new_password !== $confm_password) {
    // Passwords are NOT the same.
} else {
    // Passwords are the same.
}

Or put it the other way around if you wish:
PHP
if ($new_password === $confm_password) {
    // Passwords are the same.
} else {
    // Passwords are NOT the same.
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900