**请帮我处理数据库的表格连接,在数据库中创建表格,但我很困惑如何将其与表格连接**
这是我如何路由我的表格
<div id="register" class="animate form">
<form action="{{route('signup')}}" method="post" autocomplete="on">
<h1> Sign up </h1>
这是我的控制器
public function postSignup(Request $request)
{
$username = $request['username'];
$email = $request['email'];
$password = bcrypt($request['password']);
$user = new User();
$user->username = $username;
$user->email = $email;
$user->password = $password;
$user->save();
return redirect()->back();
}
这是我的路线文件:
Route::post('/signup',[
'uses' => UserController@postSignup,
'as'=> 'signup'
]);
答案 0 :(得分:0)
你的表格是这样的: -
<form action="{{url('signup')}}" method="post" autocomplete="on"> </from>
Or
<form action="{{ action('UserController@postSignup')}}" method="post" autocomplete="on"> </from>
尝试这条路线: -
Route::match(['get', 'post'], '/signup', 'UserController@postSignup');
希望它有所帮助!