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

davy_yg's avatar
Level 27

1/1 TokenMismatchException in VerifyCsrfToken.php line 53:

Hello,

I am receiving this error message while trying to delete an image of background profile:

1/1 TokenMismatchException in VerifyCsrfToken.php line 53:

I thought I already have the token setup.

setting.blade.php

     <table>
                                    <!-- <div class="container">
                                    <div class="row"> -->

                                    @if(isset($bgprofiles))
                                        
                                        @foreach (collect($bgprofiles)->chunk(3) as $chunk)
                                            <tr>                                                    
                                            @foreach ($chunk as $bgprofiles)
                                                <td style="padding: 8px;">
                                                    
                                                    <!-- <div class="col-sm-4"> -->
                                                    <a href="{{url('/')}}/uploads/bgprofile/{{$bgprofiles->bgprofile}}.jpg" data-lightbox="image-gallery" data-title="{{$bgprofiles->bgprofile}}" >
                                                    <img width="100px"
                                                        height="100px"
                                                        src="{{url('/')}}/uploads/bgprofile/{{$bgprofiles->bgprofile}}.jpg"/></a><br> 
                                                    <input type="radio" style="width: 70px;" name="background" value="{{$bgprofiles->bgprofile}}">

                                                        <form method="post" action="{{ Url('home/deletebgprofile/'. $bgprofiles->pic_id) }}">
                                                        <input type="hidden" name="_token" value="<?php echo csrf_token() ?>">
                                                        <input type="image" src="{{url('/')}}/images/cross.jpg" alt="Submit" style="width:35px; height:20px;">
                                                        </form>                                                             

                                                </td>                                                   
                                            @endforeach                                                 
                                            </tr>
                                        @endforeach


                                    @endif
                                    <!-- </div>  
                                    </div> -->
                                    </table>
0 likes
2 replies
Folarin's avatar

Just include {{csrf_field()}} in your form

         <form method="post" action="{{ Url('home/deletebgprofile/'. $bgprofiles->pic_id) }}">
                   {{csrf_field()}}
           <input type="image" src="{{url('/')}}/images/cross.jpg" alt="Submit" style="width:35px; height:20px;">
          </form>
36864's avatar

@Folarin <input type="hidden" name="_token" value="<?php echo csrf_token() ?>"> already adds the csrt token to the request.

@davy_yg how are you submitting your form? I don't see a button or any type="input" controls.

Please or to participate in this conversation.