samedi 4 mars 2023

Why I'm I getting a 405 Method Not Allowed when submitting forms - Laravel

I'm working on a countdown website where I have 2 forms in the same view, every time I submit 1 of those forms I'm getting a error that says:

"message": "The POST method is not supported for route /. Supported methods: GET, HEAD."

The method that I'm using in the view is a GET method and the method that I'm using in the action route of the forms are POST method.

Now, I'll show you the routes and the HTML:

My routes:

routes

HTML Form 1:

html form 1

HTML Form 2:

html form 2

I've tried by setting the hidden method with Laravel using @method('POST') in the form, but it doesn't even works, I've also tried setting the same route to the routes on the web.php file like this:

Route::get('/', function () {
    return view('welcome');
});


Route::post('/', [App\Http\Controllers\EmailController::class, 'sendEmail'])->name('send.email');
Route::post('/', [App\Http\Controllers\EmailController::class, 'saveEmail'])->name('save.email');

, but doesn't works too, every time I tried it, I was getting this error:

error

and other things that I have tried by watching YouTube tutorials and StackOverflow posts, but how I said before nothing works

I would be very grateful if you could help me.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire