• Register
0 votes
254 views

Problem :

I am facing following error while trying to login from the form:

Symfony \ Component \ HttpKernel \ Exception \

MethodNotAllowedHttpException

No message

 

The following is my route:

Route::get('/', ['as' => '/', 'uses' => 'LoginController@getLogin']);
Route::get('/login', ['as' => 'login', 'uses' => 'LoginController@getLogin']);
Route::group(['middleware' => ['autheticates', 'roles']], function (){
Route::get('/logout', ['as' => 'logout', 'uses' => 'LoginController@getLogout']);
Route::get('/dashboard', ['as' => 'dashboard', 'uses' => 'DashboardController@dashboard']);
});

The following is form tag:

<form class="login-form" action="{{ route('login') }}" method="post">
6 5 3
7,540 points

2 Answers

0 votes

Solution :

I have gone through your post. The error is in the route which you have defined. It is the get and you should change it to post

change your route as follows:

Your route:

Route::get('/login', ['as' => 'login', 'uses' => 'LoginController@getLogin']);

Change to this route:

Route::post('/login', ['as' => 'login', 'uses' => 'LoginController@getLogin']);

action="{{ route('login') }}" # form Submit action

OR

Route::post('/', 'PostController@index');

Route::post('/posts/create', 'PostController@create');

Route::post('/posts', 'PostController@store');

Post or get..if you successfully pass post value than only use post.

OR

 

This problem genrally appears only if you have forgotten to attach the method on your form or the error in Route method.

So please confirm that you added method POST/GET in your form. And please don't forget in making the matching route as follows:

<form method="POST">

If your form has method post then make post route like below.

Route::post();

I hope you understood the method.

9 7 4
38,600 points
0 votes

Solution:

Error in the route you've identified. Its get and must change to post

change this

Route::get('/login', ['as' => 'login', 'uses' => 'LoginController@getLogin']);

To this

Route::post('/login', ['as' => 'login', 'uses' => 'LoginController@getLogin']);
action="{{ route('login') }}" # form Submit action
Route::post('/', 'PostController@index');

Route::post('/posts/create', 'PostController@create');

Route::post('/posts', 'PostController@store');

Post or get.in case you pass post value than use post.

View: create.blade.php

@extends('layouts.main')

@section('content')

	<h1>Create new account</h1>

    {{ Form::open(['route' => 'account-create-post']) }}
    
	    <div>
	        {{ Form::label('email', 'Email:') }}
	        {{ Form::email('email') }}
	       @if($errors->has('email')){{$errors->first('email')}}@endif
	    </div>

	    <div>
	        {{ Form::label('username', 'Username:') }}
	        {{ Form::text('username') }}
	       @if($errors->has('username')){{$errors->first('username')}}@endif
	    </div>

	    <div>
	        {{ Form::label('password', 'Password:') }}
	        {{ Form::password('password') }}
	       @if($errors->has('password')){{$errors->first('password')}}@endif
	    </div>

	    <div>
	        {{ Form::label('password_confirm', 'Confirm password:') }}
	        {{ Form::password('password_confirm') }}
	       @if($errors->has('password_confirm')){{$errors->first('password_confirm')}}@endif
	    </div>

	    <div>{{ Form::submit('Create account') }}</div>

    {{ Form::close() }}


@stop

Controller: AccountController.php

<?php

class AccountController extends BaseController {

	public function getCreate(){
		return View::make('account.create');
	}

	public function postCreate(){
		return 'Hello.';
	}

}

Routes.php

<?php

Route::get('/', array(
	'as' => 'home',
	'uses' => 'HomeController@home'
));

/*
/Unauthenticated group
*/
Route::group(array('before' => 'guest'), function(){

	/*
	/ CSRF group
	*/
	Route::group(array('before' => 'csrf'), function(){

		/*
		/ Create account (POST)
		*/
		Route::get('/account/create', array(
			'as' => 'account-create-post',
			'uses' => 'AccountController@postCreate'
		));

	});

	/*
	/ Create account (GET)
	*/
	Route::get('/account/create', array(
		'as' => 'account-create',
		'uses' => 'AccountController@getCreate'
	));

});

 

10 6 4
31,120 points

Related questions

0 votes
2 answers 40 views
40 views
Problem : I want to get something very basic running. I am used to the CI and now learning the Laravel 4, and their docs are not making it easy! Anyways, I want to create the login form and just make sure that the data is ... below exception: &ldquo;Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException&rdquo; Any help in resolving above error will be greatly appreciated.
asked Jan 24 jwilliam 3.9k points
0 votes
1 answer 1.7K views
1.7K views
Problem : I got stuck on below error I am trying to configure my SMTP mail on laravel &ldquo;Expected response code 250 but got code "530", with message "530 5.7.1 authentication required "&rdquo; Below is the configuration on .env MAIL_DRIVER=smtp MAIL_HOST=smtp.mailtrap.io ... I have tried to authenticate my SMTP on the env but I keep facing the above error so for now I am stuck on that error.
asked Feb 4 jwilliam 3.9k points
0 votes
1 answer 217 views
217 views
Problem : I am trying to learn the pSQL. I recently moved my Laravel App from the MySQL to pSQL. But now I keep on getting below error. &ldquo;The Response content must be a string or object implementing __toString(), "boolean" given.&rdquo; I have the API that was returning my promotion before but now it only returns the above error. Can anyone suggest me solution on above error ?
asked Feb 13 mphil 2.3k points
0 votes
1 answer 203 views
203 views
Problem : I am currently using the Mac OS Yosemite and Laravel 5.0. I am new to Laravel 5.0. In the local environment whenever I run the below command php artisan migrate I always encounter below error : &ldquo;Access denied for user 'homestead'@'localhost' (using password: YES)&rdquo; I am unable to fix above error. Any clue to fix the above error?
asked Feb 13 mphil 2.3k points