R
R
Ruslan2015-03-16 15:31:02
Laravel
Ruslan, 2015-03-16 15:31:02

How does the POST method work in Laravel routes?

Hello.
I just started learning Laravel (this is my first framework in principle) and almost immediately ran into a difficulty.
I'm creating a simple form with one text field and a submit button (Without Laravel's help) in a test.php view file that is called from the "MyFirstController" controller.
In the routes.php file I write (in the form: action="act_form"):

Route::post('test/act_form', function()
{
  return "Форма обработана!";
});

But I get an error.
I tried instead of "Route::post('test/act_form', ..." to write "Route::post('act_form', ...", it still does not help. Please tell me
how to correctly catch the form from routes. php
The entire routes.php file, just in case:
<?php
Route::get('/', function()
{
    return "Hello!";
});

Route::get('test', '[email protected]');

Route::post('test/act_form', function()
{
  return "Форма обработана!";
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ruslan, 2015-03-17
@rusl2401

Thank you all for watching) I figured it out with the help of kind people on the forum: https://laravel.ru/forum/viewtopic.php?pid=4000
In short, it was necessary to use a token in the form.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question