【问题标题】:Object not found in Laravel 5 when I submit a form当我提交表单时,在 Laravel 5 中找不到对象
【发布时间】:2020-12-31 07:58:04
【问题描述】:

当点击提交按钮时,页面从 (localhost/cms/public/posts/create) 重定向到 (localhost/posts),然后出现错误页面。试图使用控制器显示输入文本。下面是我的代码

web.php Route::resource('/posts','PostsController');

PostController.php

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

public function store(Request $request)
{
  //
  return $request->get('title');
}

views/posts/create.blade.php

<html>
  <head>
    <title></title>
  </head>
  <body>
    <h1>Form</h1>
    <form method="post" action="/posts">
      <input type="text" name="title" placeholder="enter title">
      <input type="submit" name="submit">
    </form>
  </body>
</html>

error page

【问题讨论】:

    标签: php laravel-5 error-handling xampp localhost


    【解决方案1】:

    Action 应该是你试图显示的页面的名称 试试

    【讨论】:

      猜你喜欢
      • 2017-08-11
      • 2015-08-16
      • 2012-10-01
      • 2020-06-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-10
      相关资源
      最近更新 更多