1

What I'm trying to do is back to the previous page using the browser button after validation fails many times.

But what happening is taking me back to the previous request till I reach the previous page for example, if validation fails three times must I back three times to reach the previous page.

It looks the browser save URLs every time back to the same page.

https://homemaker/public/worktype <-- 1
https://homemaker/public/worktype/1/edit <-- 2 go to edit the page and hit edit to make validation fail 
https://homemaker/public/worktype/1/edit <-- 3 back with error message
https://homemaker/public/worktype/1/edit <-- 4 doing step 2 agine 

Now I must back three times to get the previous page and if I go forward .

The same thing happened in any page include to form validation.

enter image description here

If I click on the forward button it back to edit page but the validation still appears

enter image description here

Update funaction in controller

 public function update(Request $request, WorkersType $workersType)
    {


        $rules = ['work_type' => 'required|string|max:45|unique:workers_types,worktype'];

        $result = Validator::make($request->all(), $rules);

        if($result->fails())
        {
            return back()->withErrors($result)->withInput($request->all())->with('error', __('Something Wrong'));
        }

        $worktype = WorkersType::find($workersType->id); // get the selected work type from id
        $worktype->worktype = $request->get('work_type');
        $worktype->save();
        return redirect()->route('worktype.index')->with('success', __('Edit Successfully'));

    }

I use laravel 7, browser chrome, PHP 7.4, XAMPP 3.2.4

Why does this happen? it is annoying

Is this normal in the browser?

Is there any way to fix this or bypass it?

Please help

SWAT 10101
  • 127
  • 3
  • 16
  • You could do it with javascript or php. Javascript: https://stackoverflow.com/questions/28028297/js-window-history-delete-a-state PHP: https://stackoverflow.com/questions/10010858/is-it-possible-to-trace-browser-history-in-a-php-code/10010982 – Jordan Jul 23 '20 at 00:59

0 Answers0