gpt4 book ai didi

php - Laravel 中未定义路由 [signup]

转载 作者:行者123 更新时间:2023-12-02 00:14:33 28 4
gpt4 key购买 nike

我是 Laravel 新手。我正在学习如何创建用户注册页面。一切正常,但我陷入了一个简单的问题。

ErrorException in UrlGenerator.php line 304: Route [signup] not defined. (View: C:\Program Files (x86)\Ampps\www\social\resources\views\welcome.blade.php)

但我定义了注册路线。这是我的 routes.php 文件

Route::get('/', function () {
return view('welcome');
})->name('home');
Route::post('/signup', [
'uses' => 'UserController@postSignUp',
'as' => 'signup'
]);

这是我的UserController.php

class UserController extends Controller
{
public function postSignUp(Request $request)
{
$email = $request['email'];
$first_name = $request['frist_name'];
$password = bcrypt($request['password']);


$user = new User();
$user->email = $email;
$user->frist_name = $first_name;
$user->password = $password;

$user->save();

return redirect()->back();

Blade 文件是welcome.blade.php

 <form action="{{ route('signup') }}" method="post">
<div class="form-group">
<label for="email"> Your E-mail </label>
<input class ="form-control" type="text" id="email" name="email" >
</div>

如果有人能帮助我,我将不胜感激。谢谢

噢,抱歉。我忘记提及我正在使用 Laravel 版本:5.4.11

最佳答案

您可以将 {{route('/signup')}} 更改为 {{URL('/signup')}}

<form action="{{ URL('signup') }}" method="post">
<div class="form-group">
<label for="email"> Your E-mail </label>
<input class ="form-control" type="text" id="email" name="email" >
</div>

关于php - Laravel 中未定义路由 [signup],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42311369/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com