Route::get('/', function () {
return view('welcome');
});
Route::resource('/user', UserController::class);
Route::get('/login',[UserController::class,'login']);
Route::post('/loginCheck',[UserController::class,'loginCheck']);
Route::get('/regist',[UserController::class,'regist']);
Route::post('/registCheck',[UserController::class,'registCheck']);
public function login()
{
return view('login');
}
public function regist()
{
return view('regist');
}
public function loginCheck(Request $request)
{
$data=$request->all();
$username=$request->input('username');
$password=$request->input('password');
$res=DB::table('users')->where('name',$username)->where('password',$password)->first();
if ($res === true)
dd('登陆成功');
else
dd('登陆失败');
}
public function registCheck(Request $request)
{
$data=$request->all();
$username=$request->input('username');
$email=$request->input('email');
$password=$request->input('password');
$res=DB::insert('insert into users (name, email ,password) values (?, ? ,?)', [$username, $email, $password]);
if ($res === true)
dd('注册成功');
else
dd('注册失败');
}
|