11月8日PHP练习《留言板》
一、要求
二、示例页面
三、网页代码及网页显示
1.denglu.php 登录页面
<!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>
<style type="text/css">
*{ margin:0px auto; padding:0px}
#aa{ width:400px; height:89px; font-size:36px; color:#39F; text-align:center; line-height:89px; vertical-align:middle; border-bottom:1px solid #999}
.bb{ width:400px; height:59px}
.cc{ width:159px; height:59px; float:left; font-size:20px; text-align:right; line-height:59px; vertical-align:middle}
.dd{ width:200px; height:59px; float:left}
.ee{ width:150px; height:30px; text-align:center; margin-top:15px}
.ff{ width:80px; height:30px}
</style>
</head> <body>
<form action="dengluchuli.php" method="post">
<div style="width:400px; height:259px; margin-top:100px; border:1px solid #999">
<div id="aa">汉企网络0904留言板</div>
<div class="bb">
<div class="cc">用户名:</div>
<div class="dd"><input id="yonghuming" class="ee" type="text" name="uid" /></div>
</div>
<div class="bb">
<div class="cc">密码:</div>
<div class="dd"><input class="ee" type="password" name="pwd" /></div>
</div>
<div style="width:400px; height:50px; text-align:center; margin-top:10px">
<input class="ff" type="submit" value="登录" />
<input class="ff" type="button" value="复位" onclick="Fuwei()" />
</div>
</div>
</form>
</body>
<script type="text/javascript">
function Fuwei()
{
document.getElementById("yonghuming").value = "";
}
</script>
</html>
2.dengluchili.php 登录处理页面
<?php
session_start();
$UserName = $_POST["uid"]; $PassWord = $_POST["pwd"]; include("DBDA.class.php");
$db = new DBDA();
$sql = "select PassWord from yuangong where UserName='$UserName'"; $mm = $db->StrQuery($sql); if($PassWord !="" && $PassWord==$mm)
{
$_SESSION['views']=$UserName;
header("location:main.php");
}
else
{
echo "用户名或密码输入错误";
}
3.main.php 主页面,显示所有的信息。
<?php
session_start();
?> <!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>
<?php include("DBDA.class.php");
$db = new DBDA(); $sall = "select count(*) from liuyan";
$total = $db->StrQuery($sall); include("../page.class.php");
$page = new Page($total,20); $sql = "select * from liuyan ".$page->limit; $result = $db->Query($sql); foreach($result as $v)
{
}
?>
<br />
<div><a href="fabuxinxi.php">发布信息</a> <a href="tuichuchuli.php">退出系统</a></div>
<br />
<table width="50%" border="1" cellpadding="0" cellspacing="0">
<tr>
<td>发送人</td>
<td>接收人</td>
<td>发送时间</td>
<td>信息内容</td>
</tr>
<?php
foreach($result as $v)
{
echo "<tr><td>$v[1]</td><td>$v[2]</td><td>$v[3]</td><td>$v[4]</td></tr>";
}
?>
</table>
<?php
echo $page->fpage();//显示表格下方的数据和页面的信息。
if(empty($_SESSION["views"]))
{
header("location:denglu.php");
exit;
}
?>
</body>
</html>
4.fabuxinxi.php 发布信息页面
<?php
session_start();
?>
<!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>
<style type="text/css">
*{ margin:0px; padding:0px}
.aa{ width:300px; height:40px; border:2px solid #999; border-bottom:0px; text-align:center; line-height:40px; vertical-align:middle}
.bb{ width:80px; height:30px}
#text1{ float:left; margin-top:10px; width:150px; height:20px; margin-left:2px}
</style>
</head>
<body>
<form action="fabuxinxichuli.php" method="post" onclick="return true">
<div style="position:relative; left:100px; top:40px">
<div><a href="chakanxinxi.php">查看信息</a> <a href="tuichuchuli.php">退出系统</a></div>
<br />
<div class="aa">
<div style="float:left; width:100px; height:40px; text-align:right">接收人:</div>
<!--<input id="text1" type="text" name="jieshouren" />-->
<select name="jishouren" style="width:100px; height:25px; margin-top:8px; margin-left:-100px">
<option selected="selected">所有人</option>
<?php
include("DBDA.class.php");
$db = new DBDA();
$sql = "select firend from firend";
$result = $db->Query($sql);
foreach($result as $v)
{
echo "<option>$v[0]</option>";
}
?>
</select>
</div>
<div class="aa" style="height:90px">
<div style="float:left; width:100px; height:90px; text-align:right; line-height:90px; vertical-align:middle">信息内容:</div>
<div style="text-align:left"><textarea id="text2" name="xinxineirong" style="margin-top:4px; height:80px"></textarea></div>
</div>
<div class="aa" style="border-bottom:2px solid #999">
<input class="bb" type="submit" value="发送" />
<input class="bb" type="button" value="复位" onclick="Fuwei()" />
</div>
</div>
</form>
<?php
if(empty($_SESSION["views"]))
{
header("location:denglu.php");
} ?>
</body>
<script type="text/javascript">
function Fuwei()
{
document.getElementById("text1").value = "";
document.getElementById("text2").value = "";
}
</script>
</html>
5.fabuxinxichuli.php 发布信息处理页面
<?php
session_start();
$fasongren = $_SESSION['views'];
$time = date("Y-m-d h:i:s");
$jieshouren = $_POST["jieshouren"];
$xinxineirong = $_POST["xinxineirong"]; include("DBDA.class.php");
$db = new DBDA(); $sql ="insert into liuyan values('','{$fasongren}','{$jieshouren}','{$time}','{$xinxineirong}')";
$db->Query($sql,0);
if(empty($_SESSION["views"]))
{
header("location:denglu.php");
}
else
{
header("location:main.php");
}
6.chakanxinxi.php 只显示和登陆者有关系的信息
<?php
session_start();
?>
<!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>
<?php
$sender = $_SESSION['views'];
$Recever = $_SESSION['views'];
include("DBDA.class.php");
$db = new DBDA(); $sall = "select count(*) from liuyan";
$total = $db->StrQuery($sall); include("../page.class.php");
$page = new Page($total,20); $sql = "select * from liuyan where Sender='$sender' or Recever='$Recever' ".$page->limit; $result = $db->Query($sql); foreach($result as $v)
{
}
?>
<br />
<div><a href="fabuxinxi.php">返回</a></div>
<br />
<table width="50%" border="1" cellpadding="0" cellspacing="0">
<tr>
<td>发送人</td>
<td>接收人</td>
<td>发送时间</td>
<td>信息内容</td>
</tr>
<?php
foreach($result as $v)
{
echo "<tr><td>$v[1]</td><td>$v[2]</td><td>$v[3]</td><td>$v[4]</td></tr>";
}
?>
</table>
<?php
echo $page->fpage();//显示表格下方的数据和页面的信息。
if(empty($_SESSION["views"]))
{
header("location:denglu.php");
exit;
}
?>
</body>
</html>
7.tuichuchuli.php 退出系统,清空session。
<?php
session_start(); unset($_SESSION); session_destroy(); header("location:denglu.php");
11月8日PHP练习《留言板》的更多相关文章
- 11月30日《奥威Power-BI智能分析报表制作方法》腾讯课堂开课啦
这么快一周就过去了,奥威公开课又要与大家见面咯,上节课老师教的三种报表集成方法你们都掌握了吗?大家都知道,学习的结果在于实际应用,想要熟练掌握新内容的要点就在于去应用它.正是基于这一要点,每一期的课程 ...
- 11月23日《奥威Power-BI报表集成到其他系统》腾讯课堂开课啦
听说明天全国各地区都要冷到爆了,要是天气冷到可以放假就好了.想象一下大冷天的一定要在被窝里度过才对嘛,索性明天晚上来个相约吧,相约在被窝里看奥威Power-BI公开课如何? 上周奥威公开 ...
- 11月16日《奥威Power-BI基于SQL的存储过程及自定义SQL脚本制作报表》腾讯课堂开课啦
上周的课程<奥威Power-BI vs微软Power BI>带同学们全面认识了两个Power-BI的使用情况,同学们已经迫不及待想知道这周的学习内容了吧!这周的课程关键词—— ...
- 11月09日《奥威Power-BI vs微软Power BI》腾讯课堂开课啦
上过奥威公开课的同学可能有一个疑问:奥威Power-BI和微软Power BI是同一个吗,为什么叫同样的名字?正如这个世界上有很多个John.Jack.Marry…一样,奥威Power-BI和微软Po ...
- 2016年11月30日 星期三 --出埃及记 Exodus 20:21
2016年11月30日 星期三 --出埃及记 Exodus 20:21 The people remained at a distance, while Moses approached the th ...
- 2016年11月29日 星期二 --出埃及记 Exodus 20:20
2016年11月29日 星期二 --出埃及记 Exodus 20:20 Moses said to the people, "Do not be afraid. God has come t ...
- 2016年11月28日 星期一 --出埃及记 Exodus 20:19
2016年11月28日 星期一 --出埃及记 Exodus 20:19 and said to Moses, "Speak to us yourself and we will listen ...
- 2016年11月27日 星期日 --出埃及记 Exodus 20:18
2016年11月27日 星期日 --出埃及记 Exodus 20:18 When the people saw the thunder and lightning and heard the trum ...
- 2016年11月26日 星期六 --出埃及记 Exodus 20:17
2016年11月26日 星期六 --出埃及记 Exodus 20:17 "You shall not covet your neighbor's house. You shall not c ...
- 2016年11月25日 星期五 --出埃及记 Exodus 20:16
2016年11月25日 星期五 --出埃及记 Exodus 20:16 "You shall not give false testimony against your neighbor.不 ...
随机推荐
- SQLServer中修改字段为空
ALTER 表名 table1 ALTER COLUMN [字段] 类型 NULL; 例如: ) COLLATE Chinese_PRC_CI_AS NULL;
- Zookeeper(一)从抽屉算法到Quorum (NRW)算法
一.抽屉算法 抽屉算法,又名鸽巢原理,它是德国数学家狄利克雷首先明确的提出来并用以证明一些数论中的问题,因此,也称为狄利克雷原则.它是组合数学中一个重要的原理. 具体算法讲的是: 第一抽屉算法: 如果 ...
- Entity Framework Code First反向生成代码
那些年我们生成的代码 早年,笨点的方法通常都是使用DbFirst先生成cs,然后把CS复制出来做些修改 后台基本上就自己使用T4来写,但是一直也没时间完善成通用的版本 MS官方 提供了EntityFr ...
- Hibernate 延迟加载和立即加载
概念 什么是延迟加载:所谓延迟加载就是当在真正需要数据的时候,才真正执行数据加载操作.可以简单理解为,只有在使用的时候,才会发出sql语句进行查询,数据是分N次读取. 什么是立即加载:所谓立即加载既是 ...
- 第9章 Java类的三大特性之一:继承
1.什么是继承 子类继承父类就是对父类的扩展,继承时会自动拥有父类所拥有的处private之外的所有成员作用:增加代码复用语法格式: class 子类名 extends 父类名{…………}第9章 Ja ...
- inverse
首先术语inverse 被翻译为反转的意思.inverse 制定了关联关系中的方向. 当set的inverse属性默认情况下,hibernate会按照持久化对象的属性变化来同步更新数据库. 得到两条s ...
- CHM打不开的解决方法
CHM打不开的解决方法 听语音 | 浏览:62240 | 更新:2013-02-04 14:58 | 标签:软件 1 2 3 4 5 6 分步阅读 一键约师傅 百度师傅高质屏和好师傅,拯救你的碎屏机 ...
- 一份关于Swift语言学习资源的整理文件
一份关于Swift语言学习资源的整理文件 周银辉 在这里下载 https://github.com/ipader/SwiftGuide
- Qt——浅谈样式表
优秀的程序,不仅要有严密逻辑,而且应该有美观的外表.从软件界面,便可看出你是否用心在做,是否是一个有思想的人. Qt样式表的术语和语法规则和HTML CSS有很多相似之处. 样式规则 Qt中样式规则由 ...
- Java 数组基础
数组 数组(Array):相同类型数据的集合. 定义数组 方式1(推荐,更能表明数组类型) type[] 变量名 = new type[数组中元素的个数]; 比如: int[] a = new int ...