請解決我的問題。如在以下情況下顯示控制器頁:如何驗證重置密碼?
Controller.php這樣
public function TeacherUpdatePassword(Request $request)
{
$this->validate($request, [
'curr_password' => 'required',
'new_password' => 'required|min:4',
'confm_password' => 'required|same:new_password',],
[
'curr_password.required' => 'Enter Current Password',
'new_password.required' => 'required|min:4',
'confm_password.required' => 'required|same:new_password',
]);
if(!Hash::check($curr_password,Auth::user()->password)){
\Session::flash('success', 'The specified password does not match.');
return Redirect('/studentresetpassword');
}
else if ($new_password !== $confm_password) {
\Session::flash('success', 'Passwords are NOT the same.');
return Redirect('/studentresetpassword');
}
else{
$request->user()->fill(['password' => Hash::make($new_password)])->save();
\Session::flash('success', 'Updated Successfully.');
return Redirect('/studentresetpassword');
}
}
Teacherresetpassword.blade.php
@extends('layouts.default')
@section('content')
<div id="profileTeacher" type="view" class="demo-section k-header">
@include('layouts.common.flash-message')
{!! Form::open(['url' => 'teacherupdatepassword', 'method' => 'post']) !!}
<form id="profileTeacherForm" method="post" action="" >
<ul id="fieldlist" >
<li>
<label style="color:Green;font-size:15px">Update Password</label>
</li>
<li>
<table id="lessonPlanTable">
<tr>
<td><label> Current Password </label> </td>
<td><input type="password" id="curr_password" name="curr_password" class="k-textbox"/ required></td>
</tr>
<tr>
<td><label> New Password </label> </td>
<td><input type="password" id="new_password" name="new_password" class="k-textbox"/ required></td>
</tr>
<tr>
<td><label> Confirm Password </label> </td>
<td><input type="password" id="confm_password" name="confm_password" class="k-textbox"/ required ></td>
</tr>
</table>
</li>
<li><br>
<button id="updateTeacherProfile" class="k-button k-primary" type="submit">Update</button>
<br><br>
</ul>
</form>
</div>
@stop
route.php
Route::get('/teacherresetpassword', function() {
return view('layouts.teacher.teacherresetpassword');
});
Route::post('/teacherupdatepassword ',
'Teacher\[email protected]');
這裏的會話閃光警報消息已經工作,但我想驗證爲空字段和密碼不匹配cases.But valida重刑沒有奏效我知道我該怎麼做,請幫助我!
將值返回到下一個窗口 {「curr_password」:「需要」,「NEW_PASSWORD」:「需要」,「confm_password」:「需要|分:6 |證實」} –
以上代碼的工作,但它顯示一個警告框,但我想驗證只有像「密碼不匹配」顯示下面的confim密碼文本框 –
@NishAnth如果我的答案是你的解決方案,然後請接受並upvote到我的答案 –