Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Vaghik's avatar

TokenMismatchException after page refresh

This is my form

<form class="records_retrieval" action="/temprorary/show" method="post">
<table id="retrieval" class="table">
    <thead>
        <th></th>
        <th>County</th>
        <th>Crime Type</th>
        <th>Date</th>
        <th>Select</th>
    </thead>
    <tbody>
        @foreach($reports as $key=>$report)
            @if($report->crime_type!="ALL")
            <tr>
                <td>{!! $key+1 !!}</td>
                <td>{!! $area_code[$report->area] !!}@if(is_admin())<a href="/report/delete/{{$report->id}}"> (x)</a>@endif</td>
                <td>{!! $report->crime_type !!}</td>
                <td>{!! $report->date !!}</td>
                <td><input type="checkbox" name="id[]" value="{{$report->id}}"></td>
            </tr>
            @endif
        @endforeach
    </tbody>
</table>
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="submit" name="show_records" value="Show Records" class="pull-right show_records_btn" >
<input type="submit" name="delete_records" value="Delete Records" class="pull-right delete_records_btn">

When i click on show records, page load normal, but after refresh it return TokenMismatchException in VerifyCsrfToken.php line 68:

In routes written

Route::post('/temprorary/show','RecordsController@temprorary');
        Route::get('/record/temprorary',['as'=>'temprory_retrieval','uses'=>'RecordsController@retrieval']);
0 likes
2 replies
thomaskim's avatar

Without seeing some code, I'm going to guess that you are returning a view from your POST route.

After you submit a form, you shouldn't return a view. You should redirect to another route that returns a view. In other words, this route:

Route::post('/temprorary/show','RecordsController@temprorary');

Should not return a view. It should redirect to another (GET) route that returns a view.

Please or to participate in this conversation.