VerifyCsrfToken.php 67行中的Laravel 5.2 TokenMismatchException

和苏帕曼

我将处理表单中的数据,然后单击“添加”按钮,并收到一个错误消息,哎呀,好像出了点问题。VerifyCsrfToken.php第67行中的TokenMismatchException:

我有看法

<form action="{{ url('siswa') }}" method="post">
  <div class="form-group">
    <label for="nisn" class="control-label">NISN</label>
    <input name="nisn" id="nisn" type="text" class="form-control">
  </div>

  <div class="form-group">
    <label for="nama_siswa" class="control-label">Nama Siswa</label>
    <input name="nama_siswa" id="nama_siswa" type="text" class="form-control">
  </div>

  <div class="form-group">
    <label for="tanggal_lahir" class="control-label">Tanggal Lahir</label>
    <input name="tanggal_lahir" id="tanggal_lahir" type="date" class="form-control">
  </div>

  <div class="form-group">
    <label for="jenis_kelamin" class="control-label">Jenis Kelamin</label>
      <div class="radio">
        <label><input name="jenis_kelamin" type="radio" value="L" id="jenis_kelamin"> Laki-laki</label>
      </div>
      <div class="radio">
        <label><input name="jenis_kelamin" type="radio" value="P" id="jenis_kelamin"> Perempuan</label>
      </div>
  </div>

  <div class="form-group">
    <input class="btn btn-primary form-control" type="submit" value="Tambah Siswa">
  </div>
</form>

然后这是我的控制器

public function create()
{
  return view('siswa.create');
}

public function store(Request $request)
{
  $siswa = $request -> all();
  return $siswa;
}
萨加尔阿罗拉

有很多选项可以解决此问题。

1)您可以在表单中使用令牌的隐藏输入字段,例如:

<input type="hidden" name="_token" value="{{ csrf_token() }}" />

2)在表单的结束标记之前添加以下代码:

{{ Form::token() }}

3)或使用laravel形式的语法来避免令牌不匹配的问题,如下所示。

 {{ Form::open(array('url' => 'foo/bar')) }}
   //
 {{ Form::close() }}

4)或在html表单结构中,您也可以使用csrf字段,如下所示。

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

5)或最后。

  <form method="POST" action="/profile">
      {!! csrf_field() !!}
  ...
  </form> 

这一定会为您服务。

谢谢

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

VerifyCsrfToken.php 67行中的TokenMismatchException

上线后,VerifyCsrfToken.php 67行中的TokenMismatchException

VerifyCsrfToken.php Laravel 5.2中的TokenMismatchException

VerifyCsrfToken.php 67行中的TokenMismatchException:将paytm与laravel 5.3集成时

使用Ajax在Laravel上的VerifyCsrfToken.php 67行中的TokenMismatchException

VerifyCsrfToken.php 67行中的Laravel 5.2 ajax上传进度栏和TokenMismatchException

Laravel 5,Forms,VerifyCsrfToken.php第46行中的TokenMismatchException

Laravel TokenMismatchException VerifyCsrfToken.php:67查找路线

laravel 5.1中的“ VerifyCsrfToken.php 53行中的TokenMismatchException:”

通过edittable提交时,VerifyCsrfToken.php中的TokenMismatchException

VerifyCsrfToken.php第53行中的TokenMismatchException:在Laravel 5.1中

Laravel 5.1中VerifyCsrfToken.php第53行中的TokenMismatchException

如何在VerifyCsrfToken.php第46行中修复TokenMismatchException:使用Ajax和laravel 5.0?

laravel模式提交表单获取错误“ VerifyCsrfToken.php第68行中的TokenMismatchException:”

VerifyCsrfToken中的TokenMismatchException-Laravel 5.1

PHP 5.6.9上的Laravel 5 TokenMismatchException

Laravel 5 TokenMismatchException登录

Laravel 5 TokenMismatchException

PHP Laravel TokenMismatchException请求

Laravel 5 TokenMismatchException仅在iFrame中

Laravel 5:在VerifyCsrfToken外部验证令牌

Laravel TokenMismatchException

Laravel Dingo API和Middleware \\ VerifyCsrfToken.php的问题

使用 Laravel5 的 facebook 应用程序的 TokenMismatchException

在Laravel 5中,如何为特定路由禁用VerifycsrfToken中间件?

TokenMismatchException Laravel 5.1

Laravel捕获TokenMismatchException

Laravel API TokenMismatchException

TokenMismatchException Laravel 联系表