public function actionLand(){
//接受用户名的值
$u_name=\Yii::$app->request->post('u_name');
//接受密码的值
$u_pwd=\Yii::$app->request->post('u_pwd');
//查询数据
$data=\Yii::$app->db->createCommand("select * from user where u_name='$u_name'")->queryAll();
//判断是否登陆成功
if(!empty($data)){
if($data[0]){
if($data[0]['u_pwd']==$u_pwd){
//开启SESSION
$session=\Yii::$app->session;
//打开SESSION
$session->open();
//接受SESSION传的值
$session->set('u_name',$u_name);
return $this->redirect(['login/list']);
}else{
echo "<script>alert('你输入的密码有误,请重新输入');location.href='index.php?r=login/index'</script>";
}
}else{
echo "<script>alert('你输入的用户名有误,请重新输入');location.href='index.php?r=login/index'</script>";
}
}else{
echo "<script>alert('你输入数据有误,请重新输入');location.href='index.php?r=login/index'</script>";
}
}
//接受用户名的值
$u_name=\Yii::$app->request->post('u_name');
//接受密码的值
$u_pwd=\Yii::$app->request->post('u_pwd');
//查询数据
$data=\Yii::$app->db->createCommand("select * from user where u_name='$u_name'")->queryAll();
//判断是否登陆成功
if(!empty($data)){
if($data[0]){
if($data[0]['u_pwd']==$u_pwd){
//开启SESSION
$session=\Yii::$app->session;
//打开SESSION
$session->open();
//接受SESSION传的值
$session->set('u_name',$u_name);
return $this->redirect(['login/list']);
}else{
echo "<script>alert('你输入的密码有误,请重新输入');location.href='index.php?r=login/index'</script>";
}
}else{
echo "<script>alert('你输入的用户名有误,请重新输入');location.href='index.php?r=login/index'</script>";
}
}else{
echo "<script>alert('你输入数据有误,请重新输入');location.href='index.php?r=login/index'</script>";
}
}