dimanche 13 septembre 2020

Object not found in Laravel 5 when I submit a form

When clicked submit button the page redirects from (localhost/cms/public/posts/create) to (localhost/posts) and then error page shows up. Was trying to display the input text using Controller. Below is my code

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



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire