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>
效果

smarty实例的更多相关文章
- smarty实例登陆、显示、分页
1.先建立登陆页面,登陆页面的PHP文件和HTML文件是分开写的. 先建立一个登陆页的PHP文件, <?php include("../init.inc.php");//引入 ...
- smarty文件夹,第一个smarty实例总结
主要是libs里面的smarty类,和init.inc.php配置文件 剩下的是php文件夹.模板文件夹,临时文件夹.缓存文件夹.配置文件夹.插件文件夹 调用main文件夹中的php文件,通过 ...
- smarty 快速上手
smarty半小时快速上手入门教程 投稿:shichen2014 字体:[增加 减小] 类型:转载 时间:2014-10-27我要评论 这篇文章主要介绍了smarty半小时快速上手入门教程,以实例的形 ...
- smarty 学习记录
smarty模版是比较大众化的一个模版,在php开发过程当中被很多开发者视为最友好的模版之一,学习smarty课程对于很多培训机构来说也是列入了培训课程之一,那么很多方面就需要我们学习了一. 安装首先 ...
- Yii集成smarty说明
1. [在protected目录下建立文件夹vendor/smarty,把smarty的类包放入其中] 2. [在extensions目录下边建立文件CSmarty.php] ...
- smarty半小时快速上手入门教程
http://www.jb51.net/article/56754.htm http://www.yiibai.com/smarty/smarty_functions.html http://www. ...
- (转)PHP模板smarty简单入门教程
转之--http://blog.163.com/zf_2011@126/blog/static/166861361201062595057962/ 如何在smarty中开始我们程序设计.PHP代码:- ...
- smarty半小时快速上手教程(转)
来源于:http://www.chinaz.com/program/2010/0224/107006.shtml 一:smarty的程序设计部分: 在smarty的模板设计部分我简单的把smarty在 ...
- Smarty 插件开发
插件包含了: functions modifiers block functions compiler functions prefilters postfilters outputfilters r ...
随机推荐
- How to recovery compiz
sudo apt install compizconfig-settings-manager dconf reset -f /org/compiz/ setsid unity dconf list / ...
- Centos使用虚拟环境创建python django工程
本地环境 通常我们登录就是后就是本地环境 本地环境下查看pip安装了那些包 pip3 list 可以看到本地环境下我们安装的是django1.11.16版本,现在我有个项目要使用django 2.0以 ...
- JVM安全点操作与测试小记
JVM的安全点学习与代码测试 监控安全点(打印JVM停顿时间,不止GC,处理毛刺): -XX:+PrintGC -XX:+PrintGCApplicationStoppedTime 取消偏向锁: -X ...
- Tmutarakan Exams URAL - 1091(莫比乌斯函数 || 容斥)
题意: 求1 - s 中 找出k个数 使它们的gcd > 1 求这样的k个数的对数 解析: 从每个素数的倍数中取k个数 求方案数 然后素数组合,容斥一下重的 奇加偶减 莫比乌斯函数的直接套模 ...
- C#中equal与==的区别
C#中equal与==的区别 来源 https://www.cnblogs.com/dearbeans/p/5351695.html C#中,判断相等有两种方式,一种是传统的==操作,一种是objec ...
- Wannafly挑战赛 22
爆零祭 T1 这题第一反应gcd啊 所以就把每个a[i]对m取模 然后求它们的gcd 即res = gcd(a[1] % m, a[2] % m, ... , a[n] % m) ans = 1 + ...
- zabbix 自定义 nginx 监控模板
打开zabbix首页→配置→模板→创建模板模板名称:Template App NGINXagent 需添加自定义监控项:UserParameter=nginx.status[*],/bin/bash ...
- Hdoj 1312.Red and Black 题解
Problem Description There is a rectangular room, covered with square tiles. Each tile is colored eit ...
- Android 错误提示: Can't create handler inside thread that has not called Looper.prepare()
Can't create handler inside thread that has not called Looper.prepare() 将 Handler handler = new Hand ...
- 【BZOJ4911】[SDOI2017]切树游戏(动态dp,FWT)
[BZOJ4911][SDOI2017]切树游戏(动态dp,FWT) 题面 BZOJ 洛谷 LOJ 题解 首先考虑如何暴力\(dp\),设\(f[i][S]\)表示当前以\(i\)节点为根节点,联通子 ...