• Register
0 votes
333 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 41 views
41 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 2.3K views
2.3K 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 306 views
306 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, 2020 mphil 2.3k points
0 votes
1 answer 350 views
350 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, 2020 mphil 2.3k points
0 votes
1 answer 53 views
53 views
Problem : Facing migration error on Laravel 5.4 with php artisan make:auth command as follows: syntax error or access violation: 1071 specified key was too long; max key length is 767 bytes
asked Nov 13, 2019 peterlaw 6.9k points
0 votes
1 answer 48 views
48 views
Problem : I recently installed a Laravel 5.0 properly by cloning it in git, and composer install, but when I ran it to my browser http://localhost/laravel/public/, it gives below message : "Whoops! looks like something went wrong. please give us a few ... I tried to copy a env.example to .env below is result &ldquo;RuntimeException in compiled.php line 5599: OpenSSL extension is required.&rdquo;
asked Feb 3, 2020 jwilliam 3.9k points
0 votes
1 answer 9 views
9 views
Problem: How to get rid of the error:failed opening required 'vendor/autoload.php'?
asked Dec 13, 2020 prog_learner 2.5k points
0 votes
1 answer 169 views
169 views
Problem: What is $_server['http_referer']? How can we use $_server['http_referer'] in laravel php.
asked Nov 16, 2020 prog_learner 2.5k points
0 votes
0 answers 51 views
51 views
I'm applying Laravel to write a service for mobile. I am trying to figure the solution. Can someone give me the hint?
asked Sep 14, 2020 Daniel Anderson 4k points