Jakiro Dragon Jakiro Dragon - 1 year ago 107
PHP Question

getting laravel local host path error (object not found)

I'm new to laravel and still learning about this framework.
I already find some question in stackoverflow but it still didnt work out for me .

My problem is :

I got this


and the route :

Route::get('users/create',['uses' => 'UserController@create']);

Inside the page theres some form like this
this is my page inside

so when i click create button it suppose to route it into store function in the user controller

Route::post('users',['uses' => 'UserController@store']);

public function store(Request $request)
return $request->all();

so the problem is when I click that create button it always redirect me to localhost/users and because of that, I cant procces my store function
any advice ?

this is my form code

<form method="post" action="/users">
<input type="text" name="name">
<input type="email" name="email">
<input type="password" name="password">
<input type="submit" value="Create">

Answer Source

The problem may be because of relative path in form action.

You should always use named routes which allow the convenient way of generation of URLs or redirects for specific routes. So you can change your route as:

Route::post('users', 'UserController@store')->name('users.create');

And in form you can write as:

 <form method="post" action="{{ route('users.create') }}">
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download