VerifyCsrfToken.php第68行中的TokenMismatchException:Laravel 5.4

时间:2017-04-14 14:31:38

标签: php laravel-5.4

发送帖子请求时发送查询帖子时,会发生错误 VerifyCsrfToken.php第68行中的TokenMismatchException

     <form action = "contact" method = "POST">
         Name <input type = "text" name ="param">
         Текст <textarea name = "" id = "" cols = "30" rows = "10></textarea> 
          <input type="submit" value = "submit">
     </form>

2 个答案:

答案 0 :(得分:1)

尝试添加表单内部{{ csrf_field() }}

<form>
  {{ csrf_field() }}
  <input >
  ...
</form>

这将为您插入csrf令牌的隐藏字段

答案 1 :(得分:1)

您的问题是您没有为此特殊方法{{csrf_field()}}提供的laravel中的csrf发送令牌 你可以在这里详细阅读laravel csrf

<form action = "contact" method = "POST">
     {{csrf_field()}}
     Name <input type = "text" name ="param">
     Текст <textarea name = "" id = "" cols = "30" rows = "10></textarea> 
      <input type="submit" value = "submit">
 </form>