Show the code for this
Assigning a new exam to a student
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a strange behavior being exhibited upon password reset in laravel 8. I hit the forgot password link, am redirected to the enter password field page. I enter the email, get the confirmation that the email was sent. I go to my email and reset the password after submitting the correct button. I log in to my application no problem. I can log out and back in again a few times to make sure everything is working. Then I log out and log in as admin, assign a new assignment to the test user (it is a lms student platform), log out and try to log in as the test student with the correct creds and get the message, "Whoops! Something went wrong. .These credentials do not match our records. " Not sure what I am doing wrong. It is in the user edit function that I assign the user a new exam. Could I be erassing their creds or token when I do this perhaps. Let me know your thoughts and if necessary I will add the appropriate code. Thanks.
P:S. Looking in the database, I can see the remember token and the password is still there.
EDIT: Assigning a new exam to a student does in fact change the hash of the user password and remember token in the database.
EDIT2: Here is my Form:
<form action="{{ route('admin.pages.students.update', $students->id) }}" method="post">
@csrf
<div class="card-body">
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label for="exampleInputEmail1">Student Name</label>
<input type="text" name="name" value="{{ $students->name }}" class="form-control" placeholder="Enter Company Name">
</div>
</div><!--End col md 3-->
<div class="col-md-3">
<div class="form-group">
<label for="exampleInputEmail1">Student's Company</label>
<select name="company_id" id="" class="form-select form-control">
<option value="">Select Company Name</option>
@foreach($companies as $company)
<option value="{{ $company->id }}" {{ ($students->company_id == $company->id) ? "selected" : "" }}>{{ $company->name }}</option>
@endforeach
</select>
</div>
</div><!--End col md 3-->
<div class="col-md-3">
<div class="form-group">
<label for="exampleInputPassword1">Student's Level</label>
<select name="level_id" id="" class="form-select form-control">
<option value="">Select Student Level</option>
@foreach($levels as $level)
<option value="{{ $level->id }}" {{ ($students->level_id == $level->id) ? "selected" : "" }}>{{ $level->name }}</option>
@endforeach
</select>
</div>
</div><!--End col md 3-->
<div class="col-md-3">
<div class="form-group">
<label for="exampleInputPassword1">Student's Teacher</label>
<select name="teacher_id" id="" class="form-select form-control">
<option value="">Select Teacher</option>
@foreach($allData as $teacher)
<option value="{{ $teacher->id }}" {{ ($students->teacher_id == $teacher->id) ? "selected" : "" }}>{{ $teacher->name }}</option>
@endforeach
</select>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label for="exampleInputPassword1">Assign Exam</label>
<select name="exam" id="" class="form-select form-control">
<option value="">Select Exam</option>
@foreach($exams as $exam)
<option value="{{ $exam->id }}">{{ $exam->title }}</option>
@endforeach
</select>
</div>
</div><!--End col md 12-->
</div><!--End Row-->
</div>
<!-- /.card-body -->
<div class="card-footer">
<button type="submit" class="btn btn-primary">Edit Student</button>
</div>
</form>
EDIT:3 Student Controller update and edit sections
public function StudentEdit($id) {
$data['students'] = User::find($id);
$data['exams'] = Oex_exam_master::where('status', '1')->get();
// dd($data['exams']);
$data['allData'] = User::where('role', 'Teacher')->get();
$data['levels'] = Level::all();
$data['companies'] = Company::all();
return view('admin.pages.students.students_edit', $data);
}
public function StudentUpdate(Request $request, $id) {
$edit = User::find($id);
$edit->name = $request->name;
$edit->teacher_id = $request->teacher_id;
$edit->level_id = $request->level_id;
$edit->company_id = $request->company_id;
$edit->exam = $request->exam;
$edit->password = Hash::make($request->password);
$edit->role = "Student";
$edit->save();
$notification = array(
'message' => 'Student Successfully Updated',
'alert-type' => 'success'
);
return Redirect()->route('admin.pages.students.view')->with($notification);
}
@ErikRobles you require them to change their password?
$edit->password = Hash::make($request->password);
Or are you hashing the password again (doble hashing) ?
Please or to participate in this conversation.