我成功更改了密码,但我在更改电子邮件时遇到了麻烦,我认为这会更容易,但出于某种原因我想不出该怎么做。
旧邮件:
新邮箱:
确认新邮箱:
这是我想制作的形式,但无法解决 Controllers 功能。
这就是我试图解决它的方式
public function changeemailPost(Request $request)
{
if (!(Hash::check($request->get('email'), Auth::user()->email))) {
return redirect()->back()->with("error","Your current e-mail does not matches with the e-mail you provided. Please try again.");
}
if(strcmp($request->get('email'), $request->get('new-email')) == 0){
return redirect()->back()->with("error","New e-mail cannot be same as your current e-mail. Please choose a different e-mail.");
}
$validate = $request->validate([
'email' => 'required',
'new-email' => 'required|string|min:6|confirmed',
]);
$user = Auth::user();
$user->email = $request['new-email'];
$user->save();
Auth::logout();
return view('auth.login');
}
这是html
<form method="POST" action="{{ route('change-emailPost') }}">
@csrf
<label>Enter your old e-mail:</label>
<fieldset class="youplay-input">
<input id="current-email" type="email" class="form-control" placeholder="Current E-Mail" name="email" required>
</fieldset>
<label>Enter your new e-mail:</label>
<fieldset class="youplay-input">
<input id="new-email" type="email" placeholder="New E-Mail" class="form-control" name="new-email" required>
</fieldset>
但我只得到这个错误
您当前的电子邮件与您提供的电子邮件不匹配。请再试一次
德玛西亚99