zoukankan      html  css  js  c++  java
  • smarty实例

    login.php代码

    <?php
    include("../init.inc.php");

    $smarty->display("login.html");

    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>
    <h1>登陆页面</h1>
    <form action="loginchuli.php" method="post">
    <div>用户名:<input type="text" name="uid" /></div>
    <div>密码:<input type="password" name="pwd" /></div>
    <div ><input type="submit" value="登陆" /></div>
    </form>
    <body>
    </body>
    </html>

    效果:

    loginchuli.php 代码

    <?php

    include("../DBDA.class.php");
    $db=new DBDA();
    $uid=$_POST["uid"];
    $pwd=$_POST["pwd"];
    $sql="select pwd from user where uid='{$uid}'";
    $mm=$db->StrQuery($sql);
    if($pwd=$mm && !empty($pwd))
    {
    header("location:main.php");
    }

    main.php 代码

    <?php
    include("../init.inc.php");
    include("../DBDA.class.php");
    $db=new DBDA();
    $tj=" 1=1 ";
    if(!empty($_GET["name"]))
    { $n=$_GET["name"];
    $tj="name like'%{$n}%'";
    }
    $ztj=" where {$tj} ";
    $sall=" select count(*) from course ".$ztj;
    $zts=$db->StrQuery($sall);
    include("../page.class.php");
    $page=new Page($zts,5);

    $sql=" select * from course ".$ztj.$page->limit;
    $arr=$db->Query($sql);
    $smarty->assign("fenye",$page->fpage());
    $smarty->assign("shuzu",$arr);
    $smarty->display("main.html");

    main.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="main.php" method="get">
    <div><input type="text" name="name" />
    <input type="submit" value="查找" />
    </div>
    </form>
    <table width="100%" cellpadding="0px" cellspacing="0px" border="1px">
    <tr>
    <td>代号</td>
    <td>课程</td>
    <td>类型</td>
    <td>操作</td>


    </tr>
    <{foreach $shuzu as $v}>

    <tr>
    <td><{$v[0]}></td>
    <td><{$v[1]}></td>
    <td><{$v[2]}></td>
    <td><a href="xiugai.php?code=<{$v[0]}>">修改</a></td>


    </tr>
    <{/foreach}>
    </table>
    <div><{$fenye}></div>

    </body>
    </html>

    效果:

    xiugai.php

    <?php
    include("../init.inc.php");
    include("../DBDA.class.php");
    $db=new DBDA();
    $code=$_GET["code"];
    $sql="select * from course where code='{$code}'";
    $arr=$db->Query($sql);
    $smarty->assign("course",$arr[0]);
    $smarty->display("xiugai.html");

    xiugai.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="update.php" method="post">
    <div>代号:<input type="text" name="code" value="<{$course[0]}>" /></div>
    <div>课程:<input type="text" name="course" value="<{$course[1]}>" /></div>
    <div>类型:<input type="text" name="type" value="<{$course[2]}>"/></div>
    <input type="submit" value="修改" />
    </form>
    </body>
    </html>

    效果

  • 相关阅读:
    Swagger入门
    UOS
    Java多线程
    英语语法小知识-Unit1
    MVVM
    Vue入门
    Mybatis入门
    Python pip install
    js 触发LinkButton点击事件,执行后台方法
    ajax 请求 ascx
  • 原文地址:https://www.cnblogs.com/F4natasy/p/6513958.html
Copyright © 2011-2022 走看看