• Register
0 votes
440 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

Please log in or register to answer this question.

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 49 views
49 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, 2020 jwilliam 3.9k points
0 votes
1 answer 13 views
13 views
Problem: no application encryption key has been specified. laravel.
asked Feb 24 Ethan ross 2.3k points
0 votes
1 answer 17 views
17 views
Problem: why is this still happinig with me ? Expected response code 250 but got code "530", with message "530 5.7.1 authentication required ".
asked Mar 6 Wafa Abu Yousef 6.1k points
0 votes
1 answer 2.9K views
2.9K 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, 2020 jwilliam 3.9k points
0 votes
1 answer 2 views
2 views
Problem: Need help to solve this problem," symfony\component\httpkernel\exception\httpexception ".
asked 21 hours ago zayed1 24.7k points
0 votes
1 answer 2 views
2 views
Problem: Help me here,I am not getting this problem," Symfony\component\httpkernel\exception\notfoundhttpexception ".
asked 22 hours ago zayed1 24.7k points
1 vote
1 answer 3 views
3 views
Problem : I am new in laravel. I need help understanding this error: FatalErrorException in ProjectsController.php line 70: Call to undefined function App\Http\Controllers\DateTime() What Can I do?
asked 6 days ago Shovo210 13.2k points
0 votes
1 answer 3 views
3 views
Problem: I got the following error > clang: error: unsupported option '-fopenmp'
asked Mar 30 Azlan2020 2.3k points
0 votes
1 answer 2 views
2 views
Problem: I found an error > class 'barryvdh\debugbar\serviceprovider' not found
asked Mar 29 Azlan2020 2.3k points
0 votes
1 answer 12 views
12 views
Problem: I can't figure it out the error > class 'barryvdh\dompdf\serviceprovider' not found
asked Mar 26 Azlan2020 2.3k points