Support the ongoing development of Laravel.io →
Input Forms

Hello,

I'm trying to pass the data of the form to the post route, but I always get the "MethodNotAllowedHttpException". I don't know why. I hope someone can help me. Thank you :)

...Here is the form code:

<form action="/backoffice/customer/create/" method="POST" accept-charset="UTF-8">
            <div class="row">
                <div class="col s4">
                    <input class="inputNewCustomer" type="text" name="newCustomerInput" maxlength="25" placeholder="Name of Customer">
                    <input name="_token" type="hidden" id="_token" value="{{ csrf_token() }}" />
                </div>
                <div class="col s8">
                    <button class="btn waves-effect waves-light light-green" type="submit" value="Save">create Customer</button>
                </div>
            </div>
        </form>

....Here is the route:

Route::post('backoffice/customer/create', [
    'as' => 'createCustomer', 'middleware' => 'auth', 'uses' => 'BackofficeController@createCustomer'
]);


....and the function in the controller:

public function createCustomer(){
        $customer = new Customer;
        $customer->customer_name = Input::get('newCustomerInput');
        $customer->save();
        //Log::debug("test");
        //displayCustomers();
        return Redirect::to('backoffice/customer');
    }
Last updated 2 years ago.
0

open dev tools and see if your browser is actually doing a POST not a GET

also try changing action="/backoffice/customer/create/" to action="{{ route('createCustomer') }}"

0

astroanu said:

open dev tools and see if your browser is actually doing a POST not a GET

also try changing action="/backoffice/customer/create/" to action="{{ route('createCustomer') }}"

Hi, yeah it works with action="{{ route('createCustomer') }}"

thank you ;)

0

is your Route::post inside a Route::group ?

0

Is it that last / in action ?

/backoffice/customer/create

Instead of

/backoffice/customer/create/

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.