i am working on a settings page were a user sees his prefilled username and email in the input fields. I like to detect (without jQuery đ) if the user changed the prefilled values on the inputs.
For the password reset fields (not prefilled) i use the follwing logic:
if($request['password'] != ""){
if(!(Hash::check($request['password'], Auth::user()->password))){
return redirect()->back()->with('error', 'Your password does not match with the password you provided.');
}
if(strcmp($request['password'], $request['new_password']) == 0){
return redirect()->back()->with('error', 'New password cannot be same as your old one.');
}
$validation = $request->validate([
'password' => 'required',
'new_password' => 'required|string|min:6|confirmed',
]);
$user->password = bcrypt($request['new_password']);
$user->save();
return redirect()->back()->with('alert-success', 'Password changed
successfully');
}
How can i check if the user changed the prefilled code to use the following procedure:
if($request[''] ????? ""){
$user = Auth::user();
$user->name = $request['name'];
$user->email = $request['email'];
$user->save();
}
Thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire