The controller-defined template corresponds to the corresponding data table corresponding to the corresponding view HTML file
<?php
namespace Home\model;
Use Think\model;
Class Usermodel extends model{
Protected $trueTableName = ' user ';
User Registration
Public Function Ulikeuserregister ($username, $userpassword) {
Data validation
if (Empty ($username) | | Empty ($userpassword)) {
return false;
}
Determine if the user exists
Implementing a registration operation
if ($this->noactiveregister ($username)) {
$Ulike =array (
' Username ' = $username,
' Password ' = $userpassword,
' Time ' =>time ()
);
Echo $Password;
$this->create ($Ulike);
return $this->add ();
}else{
echo "Your user name already exists, please re-enter!" ";
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;//must be careful
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 () {
}
}
?>
Controller view Template Data mapping relationship