首先需要区分php页面和html页面
php文件放在main文件夹里面 html放在templates文件夹里面
1.需要的php文件
<?php include("../init.inc.php");//引入入口文件 $smarty->display("login.html");//在login.html中显示
2.login.html页面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<h1>登录页面</h1>
<form action="loginchuli.php" method="post">
<div>用户名:<input type="text" name="uid" /></div>
<div>密码:<input type="password" name="pwd" /></div>
<input type="submit" value="登录" />
</form>
</body>
</html>
3.loginchuli.php页面 关键页面
<?php include("../DBDA.php"); $db = new DBDA(); $uid = $_POST["uid"]; $pwd = $_POST["pwd"]; $sql = "select pwd from users where uid='{$uid}'"; $mm = $db->StrQuery($sql); if($mm==$pwd && !empty($pwd)) { header("location:main.php"); }
关键一步是把引入来的值写成变量 然后造sql语句