<?php namespace HomeController; use ThinkController; class LoginController extends Controller{ public function login(){ //显示页面 if(empty($_POST)){ $this->show(); }else{ //实现登录逻辑 $uid = $_POST["uid"]; $pwd = $_POST["pwd"]; $db = D("Users"); $arr = $db->find($uid); if($arr["pwd"]==$pwd&&!empty($pwd)){ $url = U("mains"); $this->success("登录成功!",$url); }else{ $this->error("登陆失败!");//默认跳转到上一个界面 } } } public function mains(){ } }
<html> <head> </head> <body> <form action="" method="post"> <div>用户名:<input type="text" name="uid" /></div> <div>密码:<input type="password" name="pwd"/></div> <input type="submit" value="登录"/> </form> </body> </html>