The previous two articles have implemented the user login interface and verification, and now look at what the backend is going to do (based on ThinkPHP5). For example, when a student's landing is successful, the student interface is entered, and in this interface, students can submit assignments to see how their homework is being corrected. When the user entered the user name and password in the above interface, after selecting the student user, point login, will enter the Dologin method (located in Controller\index\account\dologin), the code is as follows:
Public functionDologin () {$kind=$_post[' Kind ']; if($kind= = ' Tea ') { $user=usermodel::get ([' username ' =$_post[' username '], ' password ' =MD5($_post[' pwd '])]); if($user) { if($user->power== ' Common ') Echo"Successful teacher Landing"; Else Echo' Administrator login successful '; } }Else { $stu=stumodel::get ([' Stu_no ' =$_post[' username '], ' password ' =MD5($_post[' pwd '])]); if($stu) { $_session[' Stuno ']=$stu-Stu_no; $this->success (' Landing success ', ' student/'.$stu-stu_no); } Else { $this->error (' User name or password error ')); } } }
This is only a simple implementation of the student logic. When the student landed successfully will enter the student controller's index method, of course, you need to configure the following route in rote.php:
' Index/student/:stuno ' = ' index/student/index '
The following can be handled in the student controller:
<? phpnamespace App\index\controller; use Think\controller; use app\index\model\student as Stumodel; class Student extends controller{ public function index ( $stuno Span style= "color: #000000;" ) { $stu =stumodel::get ([' Stu_no ' =>
Here is just a simple elaboration of the processing and jump logic, of course, the actual development of the more abundant functions and logic, to point the face bar, I hope you have some help.
Here is the page after successful landing:
The first top of this article to seek the net, by the author original, if need to reprint please indicate the source.
[Job Management system development combat three] user login module backend code (THINKPHP5)