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 ...
随机推荐
- Docker 部署应用、jar 工程 docker 方式部署
https://blog.csdn.net/jiangyu1013/article/details/81988342
- 学习 Spring (三) Bean 的配置项 & 作用域
Spring入门篇 学习笔记 配置项 Id: 整个 IoC 容器中的唯一标识 Class: 具体实例化的类(必须配置项) Scope: 作用域 Constructor arguments: 构造器参数 ...
- cookie中的小错误
今天在练习 cookie时意外的报了这个错. 这句话的意思是一个不识别的字符[32]出现在了cookie当中由于tomcat的版本比较高,所以在addCookie时是不能使用空格的 而在ASCII码中 ...
- c++ string类型的定义及方法
1.c++ 有两种风格的字符串形式 c风格字符串 定义及初始化 char a[]={'h','e','l','l','o','\0'} 或者 char a[]="hello&quo ...
- Oracle查看表空间,创建表空间
查看表空间: SELECT tablespace_name, file_id, file_name, round(bytes / (1024 * 1024), 0) total_space FROM ...
- kebu之rook-ceph
准备工作 所有节点开启ip_forward cat <<EOF > /etc/sysctl.d/ceph.conf net.ipv4.ip_forward = 1 net.bridg ...
- BZOJ2229[Zjoi2011]最小割——最小割树
题目描述 小白在图论课上学到了一个新的概念——最小割,下课后小白在笔记本上写下了如下这段话: “对于一个图,某个对图中结点的划分将图中所有结点分成两个部分,如果结点s,t不在同一个部分中,则称这个划分 ...
- reactNative 基础
参考:中文网,极客 一 . 基本程序: import React, { Component } from 'react'; import { Text } from 'react-native'; e ...
- MySQL免安装版,遇到MSVCR120.dll文件丢失错误的解决方案
下载 VC redist packages for x64,下载完成,点击运行即可.
- MT【302】利用值域宽度求范围
已知$f(x)=\ln x+ax+b (a>0)$在区间$[t,t+2],(t>0)$上的最大值为$M_t(a,b)$.若$\{b|M_t(a,b)\ge\ln2 +a\}=R$,则实数$ ...