dongyan3616 2017-10-30 17:15
浏览 71
已采纳

Laravel:页面已过期

I made a contact field, but when I click on the submit, I got a white screen with "The page has expired due to inactivity. Please refresh and try again." message.

The form:

 <form action="/" method="post">
                            <div class="row">
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label for="name">
                                            Név</label>
                                        <input type="text" class="form-control" id="name" placeholder="Név" required="required" />
                                    </div>
                                    <div class="form-group">
                                        <label for="phone">
                                            Telefonszám</label>
                                        <div class="input-group">
                                            <span class="input-group-addon"><span class="fa fa-phone "></span>
                                            </span>
                                            <input type="phone" class="form-control" id="phone" placeholder="Telefonszám" required="required" /></div>
                                    </div>
                                    <div class="form-group">
                                        <label for="email">
                                            E-mail cím</label>
                                        <div class="input-group">
                                            <span class="input-group-addon"><span class="fa fa-envelope"></span>
                                            </span>
                                            <input type="email" class="form-control" id="email" placeholder="E-mail cím" required="required" /></div>
                                    </div>
                                    <div class="form-group">
                                        <label for="subject">
                                            Tárgy</label>
                                        <select id="subject" name="subject" class="form-control" required="required">
                                            <option value="na" selected="">:: Tárgy:: </option>
                                            <option value="contact">Kapcsolat</option>
                                            <option value="pricequote">Árajánlat</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <label for="name">
                                            Üzenet</label>
                                        <textarea name="message" id="message" class="form-control" rows="13" cols="25" required="required"
                                            placeholder="Üzenet"></textarea>
                                    </div>
                                </div>
                                <div class="col-md-12">
                                    <button type="submit" class="btn btn-primary pull-right" id="btnContactUs">
                                        Üzenet küldése</button>
                                </div>
                            </div>
                        </form>

And I have a Route::post('/', 'Controller@Action');

What is the problem?

  • 写回答

2条回答 默认 最新

  • dongzhuzhou4504 2017-10-30 17:25
    关注

    It seems you missed the CSRF token. Take a look here: https://laravel.com/docs/5.5/csrf#csrf-introduction

    You only need to add the token in your form. Something like this:

    <form action="/" method="post">
        {{ csrf_field() }}
        ... 
    </form>
    

    I hope it works fine for you.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化