Take 3 days to get started PHP and thinkphp framework, followed by a small background, simple to use the thinkphp framework package of some classes and functions.
Now to summarize:
1 Public functionLogin ()//Login Function2 {3 if(!is_post)//determines whether the function is called for the first time4 $this-display ();5 Else6 {7 $map[' User_name ']=i (' post.username ');//Use the I () function to get the parameters from the template8 $map[' USER_PSD ']=i (' post.userpsd '));9 if(Empty($map[' user_name ']) | |Empty($map[' USER_PSD ']))//Empty () function to determine if the variable is nullTen $this->error (' User name or password not written ')); One $UserInfo= M (' zx_admin ')->where ($map),Select (); A if(Empty($UserInfo[0] [' User_name '])) - $this->error (' User name or password error ')); - Else the { -Session (' User ',$UserInfo[0]);//Set Session - $this->success (' Landing success ', U (' Index/index ')); - } + - } +}
View Code
First entry thinkphp