login页面 & lt; ! DOCTYPE html> & lt; html> & lt; head> & lt; title>登录页面& lt;/title> & lt; meta  http-equiv=" - type ",内容=" text/html; charset=utf - 8”/比; & lt;/head> & lt; body> & lt; form 行动=" LoginController.php ", method=" post "比; & lt; table> & lt; tr> & lt; td>用户名& lt;/td> & lt; td> & lt; input type=" text ", name="用户名"/祝辞& lt;/td> & lt;/tr> & lt; tr> & lt; td>密,,,,码& lt;/td> & lt; td> & lt; input type="密码",name="密码"/祝辞& lt;/td> & lt;/tr> & lt; tr> & lt; td> & lt; input 类型=疤峤弧?价值=" https://www.yisu.com/zixun/submit "/祝辞& lt;/td> & lt; td> & lt; input 类型=爸刂谩?价值=" https://www.yisu.com/zixun/reset "/祝辞& lt;/td> & lt;/tr> & lt;/table> & lt;/form> & lt;/body> & lt;/html> LoginController.PHP页面 & lt; ! DOCTYPE html> & lt; html> & lt; head> & lt; title>登录验证& lt;/title> & lt; meta  http-equiv=" - type ",内容=" text/html; charset=utf - 8”/比; & lt;/head> & lt; body> & lt; ? php //接收用户提交的用户名和密码(login页面提交的参数) $ username=$ _REQUEST['用户名'); 美元密码=$ _REQUEST['密码'];//到数据库验证,怎样写出安全的代码,防止其它用户* * *//1 .连接数据库 $链接=mysql_connect (“localhost”,“根”,“根”); 如果(! $链接){ ,,,死(“连接数据库失败”.mysql_error ()); }//2 .选择数据库 mysql_select_db(“测试”),或是死亡(“选择数据库有误”.mysql_error ());//3 .构建SQL语句,并查询//使用PDO的方式来防止SQL注入 查询美元=" select *,得到users where 用户名=?,以及密码=?,”;//1 .创建一个PDO对象 美元myPdo=new PDO (“mysql:主机=localhost;端口=3306;dbname=测试”,“根”,“根”);//2 .设置字符编码 美元myPdo→exec (set name  utf8);//3 .预处理查询美元 pdoStatement=myPdo→美元准备($查询);//4 .把接收到的用户和密码填入 美元pdoStatement→执行(数组(用户名、密码)美元);//5 .取出结果 res=pdoStatement→美元fetch (); 如果(空(res)美元){ ,,,echo “失败| & lt; a  href=' https://www.yisu.com/zixun/Login.php '祝辞try 用login”; 其他}{ ,,,头(地点:ManageUsers.php); } 比; & lt;/body> & lt;/html> ManageUsers.PHP页面 & lt; ! DOCTYPE html> & lt; html> & lt; head> & lt; title>登录验证& lt;/title> & lt; meta  http-equiv=" - type ",内容=" text/html; charset=utf - 8”/比; & lt;/head> & lt; body> 你成功! & lt;/body> & lt;/html>