Jasmel Pc
Jasmel Pc

Reputation: 535

laravel post request results in an error that method not allowed

<form id="login-form"  action="brand-dashboard" method="post">
        <span class"email">email</span>
        <input type="email" name="email">
        <span class"email">password</span>
        <input type="password" name="password"><br><br>
        <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">   
        <input type="submit" value="login">
</form> 

this is in my view page..then in my route..

Route::get('/brand-dashboard','BrandsController@auth_brand_admin');

in my Brands controller..i use the method like

public function auth_brand_admin()
    {               
        return ('sample text');
    }

but i got error when submiting the form ..the error is..

MethodNotAllowedHttpException in RouteCollection.php 

Upvotes: 0

Views: 62

Answers (1)

xAoc
xAoc

Reputation: 3588

Change your code to this

Route::post('/brand-dashboard','BrandsController@auth_brand_admin');

It's because you register route with GET method but send POST request.

Upvotes: 3

Related Questions