控制器定义的模板对应相应的数据表 也对应相应的视图html文件
<?php
namespace Home\Model;
use Think\Model;
class UserModel extends Model{
protected $trueTableName=‘user‘;
//用户注册
public function UlikeUserRegister($username,$userpassword){
//数据校验
if (empty($username)||empty($userpassword)){
return false;
}
//判断用户是否存在
//实现注册操作
if($this->NoActiveRegister($username)){
$Ulike=array(
‘Username‘=>$username,
‘Password‘=>$userpassword,
‘Time‘=>time()
);
echo $Password;
$this->create($Ulike);
return $this->add();
}else{
echo "您的用户名已经存在,请您重新输入!";
return false;
}
}
public function NoActiveRegister($username){
echo $username;
if(empty($username)){
return false;
}else{
$count = $this->where(array(
‘username‘ => $username
))->count();
echo $count;
}
if($sum==0){
return 1;
}else{
return 0;
}
}
}
?>
<?php
namespace Home\Controller;
use Think\Controller;
use Home\Model\UserModel;//一定小心
class userController extends Controller{
public function Register()
{
$usertable=D(‘user‘);
$username="lilang";
$userpassword="ulike";
$r=$usertable->UlikeUserRegister($username,$userpassword);
// dump($r);
}
public function Login()
{
}
public function Logout(){
}
public function ChangPassword(){
}
}
?>