Anibal Cardozo
Anibal Cardozo

Reputation: 577

MethodNotAllowedHttpException Laravel 4

Form open section

{{Form::open(array('action' => 'HomeController@register')) }}

my HomeController

public function register()
{
    $user = new User;

    $user->password = Hash::make(Input::get('password'));
    $user->email = Input::get('email');
    $user->house = Input::get('house');
    $user->phone = Input::get('phone');
    $user->name = Input::get('name');
    $user->last_name = Input::get('last_name');

    $user-> save();
    return Redirect::to('/');
}    

Routes

Route::get('/register','HomeController@showRegister');
Route::get('/home/register','HomeController@register');

the form is showing correctly but when i submit the form i got this error:

 Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException

Upvotes: 0

Views: 143

Answers (1)

Antonio Carlos Ribeiro
Antonio Carlos Ribeiro

Reputation: 87789

MethodNotAllowedHttpException means that the route is good but the method is wrong.

You must create it as a POST route:

Route::post('/home/register','HomeController@register');

Upvotes: 1

Related Questions