一、要求

二、示例页面

三、网页代码及网页显示

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>&nbsp;&nbsp;<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>&nbsp;&nbsp;<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练习《留言板》的更多相关文章

  1. 11月30日《奥威Power-BI智能分析报表制作方法》腾讯课堂开课啦

    这么快一周就过去了,奥威公开课又要与大家见面咯,上节课老师教的三种报表集成方法你们都掌握了吗?大家都知道,学习的结果在于实际应用,想要熟练掌握新内容的要点就在于去应用它.正是基于这一要点,每一期的课程 ...

  2. 11月23日《奥威Power-BI报表集成到其他系统》腾讯课堂开课啦

    听说明天全国各地区都要冷到爆了,要是天气冷到可以放假就好了.想象一下大冷天的一定要在被窝里度过才对嘛,索性明天晚上来个相约吧,相约在被窝里看奥威Power-BI公开课如何?        上周奥威公开 ...

  3. 11月16日《奥威Power-BI基于SQL的存储过程及自定义SQL脚本制作报表》腾讯课堂开课啦

           上周的课程<奥威Power-BI vs微软Power BI>带同学们全面认识了两个Power-BI的使用情况,同学们已经迫不及待想知道这周的学习内容了吧!这周的课程关键词—— ...

  4. 11月09日《奥威Power-BI vs微软Power BI》腾讯课堂开课啦

    上过奥威公开课的同学可能有一个疑问:奥威Power-BI和微软Power BI是同一个吗,为什么叫同样的名字?正如这个世界上有很多个John.Jack.Marry…一样,奥威Power-BI和微软Po ...

  5. 2016年11月30日 星期三 --出埃及记 Exodus 20:21

    2016年11月30日 星期三 --出埃及记 Exodus 20:21 The people remained at a distance, while Moses approached the th ...

  6. 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 ...

  7. 2016年11月28日 星期一 --出埃及记 Exodus 20:19

    2016年11月28日 星期一 --出埃及记 Exodus 20:19 and said to Moses, "Speak to us yourself and we will listen ...

  8. 2016年11月27日 星期日 --出埃及记 Exodus 20:18

    2016年11月27日 星期日 --出埃及记 Exodus 20:18 When the people saw the thunder and lightning and heard the trum ...

  9. 2016年11月26日 星期六 --出埃及记 Exodus 20:17

    2016年11月26日 星期六 --出埃及记 Exodus 20:17 "You shall not covet your neighbor's house. You shall not c ...

  10. 2016年11月25日 星期五 --出埃及记 Exodus 20:16

    2016年11月25日 星期五 --出埃及记 Exodus 20:16 "You shall not give false testimony against your neighbor.不 ...

随机推荐

  1. MAC OS X的ACL扩展权限设置

    在WEB开发时,网站是以_www的用户运行的,而我在本地是以liuwencan的用户编辑的.这就带来一个问题:如果所有文件属于liuwencan,那么网站运行需要写文件时就因无权限而失败:如果所有文件 ...

  2. day1学习

    python 2 和 3 的区别 1.用户输入的命令:python 2 中是raw_input(""):python 3 中是input(""). 2.默认字符 ...

  3. mysql 主从复制配置

    环境:已经在centos下安装好mysql,安装参考:http://www.cnblogs.com/bookwed/p/5896619.html,安装好主数据库后,可以克隆一份,注意修改ip等. 19 ...

  4. Windows10的革命之路-全新UWP开发平台

    众所周知,最近几年,微软一直在操作系统上进行统一化的尝试.第一次尝试的产品——Windows 8/8.1操作系统完全谈不上成功.请看下图: 我个人认为,这并不意味着操作系统统一化的策略是错误的,只能算 ...

  5. webhdfs 使用shell下载文件

    echo "test web hdfs how to use" >> foo.txt hdfs dfs -put foo.txt / HDFS启用webhdfs之后,可 ...

  6. WPF系列 自定控件

    引言 WPF中微软提供了一些基本的控件,但是工作中这些基础的控件往往不能满足我们的需求,这个时候我们就需要根据实际的需求去开发自己的控件,但要注意不是所有功能不满足的情况都需要通过自定义控件来实现.实 ...

  7. 修改 EF的默认连接工厂为 Sql Server 而不是LocalDb

      当你用EF6创建一个新项目,不知你是否注意到默认的连接字符串使用了LocalDb而不是SQLServer.但你如果想把默认连接改用SQLSErver而不是LocalDb.这个其实很简单:只需修改下 ...

  8. Neutron 理解(14):Neutron ML2 + Linux bridge + VxLAN 组网

    学习 Neutron 系列文章: (1)Neutron 所实现的虚拟化网络 (2)Neutron OpenvSwitch + VLAN 虚拟网络 (3)Neutron OpenvSwitch + GR ...

  9. Intellij IDEA 快捷键整理(TonyCody)

    [常规] Ctrl+Shift + Enter,语句完成 "!",否定完成,输入表达式时按 "!"键 Ctrl+E,最近的文件 Ctrl+Shift+E,最近更 ...

  10. Jenkins学习三:介绍一些Jenkins的常用功能

    Jenkins其实就是一个工具,这个工具的作用就是调用各种其他的工具来达成你的目的. 1.备份.迁移.恢复jenkins 首先找到JENKINS_HOME,因为Jenkins的所有的数据都是以文件的形 ...