zoukankan      html  css  js  c++  java
  • smarty模板做登录

    首先需要区分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语句

  • 相关阅读:
    codevs 2632 非常好友
    codevs 1213 解的个数
    codevs 2751 军训分批
    codevs 1519 过路费
    codevs 1503 愚蠢的宠物
    codevs 2639 约会计划
    codevs 3369 膜拜
    codevs 3135 River Hopscotch
    数论模板
    JXOJ 9.7 NOIP 放松模拟赛 总结
  • 原文地址:https://www.cnblogs.com/xiaoming-6/p/6516806.html
Copyright © 2011-2022 走看看