简体   繁体   English

此路由不支持 GET 方法。 支持的方法:POST。 拉拉维尔 8

[英]The GET method is not supported for this route. Supported methods: POST. laravel 8

I am new at Laravel.我是 Laravel 的新手。 I am making a signup form in Laravel.我正在 Laravel 中制作注册表单。 When I use Route::post() and make this function in my controller, it gave me the error.当我使用Route::post()并在我的控制器中创建这个函数时,它给了我错误。

    <form action="{{route('userregister')}}" method="post">

and

    Route::post('/userregister',[Logincontroller::class,'userregister']);

Here is my function userregister这是我的函数 userregister

    public function userregister(Request $request)
    {
        echo 'value posted';
    }

Try with below code,试试下面的代码,

In your blade file在您的刀片文件中

<form action="{{ route('user-register') }}" method="POST">
    {{ @csrf_field() }}
</form>

In your route file Plz see documentation for route because of laravel versions uses defferent syntax在您的路由文件中,请参阅路由文档,因为 laravel 版本使用不同的语法

Route::post('/userregister',[Logincontroller::class,'userregister'])->name('user-register);

In your controller file在您的控制器文件中

public function userregister(Request $request)
{
    var_dump($request);
    exit;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 此路由不支持 GET 方法。 支持的方法:POST。 与 laravel - The GET method is not supported for this route. Supported methods: POST. with laravel 此路由不支持 GET 方法。 支持的方法:POST。 在 laravel 8 - The GET method is not supported for this route. Supported methods: POST. in laravel 8 此路由不支持 PUT 方法。 支持的方法:POST。 在 laravel 8 - The PUT method is not supported for this route. Supported methods: POST. in laravel 8 此路由不支持 GET 方法。 支持的方法:POST。 Laravel 和 Ajax - The GET method is not supported for this route. Supported methods: POST. Laravel and Ajax 此路由不支持 DELETE 方法。 支持的方法:GET、HEAD、POST。 在 laravel - The DELETE method is not supported for this route. Supported methods: GET, HEAD, POST. in laravel 此路由不支持 DELETE 方法。 支持的方法:GET、HEAD、POST。 在 laravel 7' - The DELETE method is not supported for this route. Supported methods: GET, HEAD, POST. in laravel 7' 此路由不支持 GET 方法。 支持的方法:POST。 laravel-8 - The GET method is not supported for this route. Supported methods: POST. laravel-8 此路由不支持 PUT 方法。 支持的方法:GET、HEAD、POST。 在 laravel - The PUT method is not supported for this route. Supported methods: GET, HEAD, POST. in laravel 尝试登录 Laravel API:&#39;此路由不支持 GET 方法。 支持的方法:POST。 - Trying to login to Laravel API: 'The GET method is not supported for this route. Supported methods: POST.' 此路由不支持 GET 方法。 支持的方法:POST。 在 Laravel 7.24.0 - The GET method is not supported for this route. Supported methods: POST. in Laravel 7.24.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM