码迷,mamicode.com
首页 > 其他好文 > 详细

0526留言板练习

时间:2016-05-26 22:07:17      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:

登录页面

技术分享

<!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>
<form action="dlchuli.php" method="post">
<h1>开发部内容留言板</h1>
<div>用户名:<input type="text" name="yhm" /></div><br />
<div>口 令:<input type="text" name="kl" /></div><br />
<div><input type="submit" value="登录" /> </div>
</form>




</body>
</html>

 登录处理页面

<?php
session_start();
$yhm=$_POST["yhm"];
$mm=$_POST["kl"];
include("../DBDA.php");
$db=new DBDA();
$sql="select count(*) from yuangong where UserName=‘{$yhm}‘ and PassWord=‘{$mm}‘";
$j=$db->StrQuery($sql);
var_dump($j);
if($j==1)
{
	$_SESSION["yhm"]=$yhm;
	header("location:zhu.php");
}
else
{
	echo"登录失败";
}

  主页面

技术分享

<!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><a href="fabu.php">发布消息</a>  <a href="tuichu.php">退出系统</a></h1>
<h3>留言信息:</h3>
<table width="100%" border="1" cellpadding="0" cellspacing="0">
<tr>
<td>发送人</td>
<td>发送时间</td>
<td>接收人</td>
<td>信息内容</td>
</tr>
<?php
session_start();
if(empty ($_SESSION["yhm"]))//判断用户名是否存在
{
   header("location:Untitled-1.php");
   exit;//  跳出程序	
}
$yhm=$_SESSION["yhm"];
include("../DBDA.php");
$db=new DBDA();
$sql="select * from liuyan where Recever=‘{$yhm}‘ or Recever=‘suoyou‘";
$jieguo=$db->Query($sql);
foreach($jieguo as $v)
{
	//根据循环$v[1](发送者的用户名【昵称】)在yuangong表查询发送者的名字
	$sqlf="select Name from yuangong where UserName=‘{$v[1]}‘";
	$fszxm=$db->StrQuery($sqlf);
	//根据登录者的用户名在yuangong表里查询他(接收者)的姓名
     $jieshou="";
	if($v[2]=="suoyou")
	{
		$jieshou="所有人";
	}
	else
	{
		$sqlj="select Name from yuangong where UserName=‘{$yhm}‘";
		$jieshou=$db->StrQuery($sqlj);
	}
  echo"<tr>
  <td>{$fszxm}</td>
  <td>{$v[3]}</td>
  <td>{$jieshou}</td>
  <td>{$v[4]}</td>
  </tr>";	
}
?>
</table>

</body>
</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>
<?php
session_start();
if(empty($_SESSION["yhm"]))
{
   header("location:Untitled-1.php");
   exit;	
}
$yhm=$_SESSION["yhm"];
include("../DBDA.php");
$db=new DBDA();
?>
<h1><a href="zhu.php">查看消息</a>  <a href="tuichu.php">退出系统</a></h1>
<h3>发送消息:</h3>
<form action="fschuli.php" method="post">
<div>接收人:
<select name="jsr">
<option value="suoyou">所有人</option>
<?php
$sql1="select Firend from firend where Me=‘{$yhm}‘";
$py=$db->Query($sql1);
foreach($py as $v)
{
    $sql2="select Name from yuangong where UserName=‘{$v[0]}‘";
	$jsr=$db->StrQuery($sql2);	
	echo"<option value=‘{$v[0]}‘>{$jsr}</option>";
}
?>
</select>
</div>
<br />
<div>信息内容:
<textarea name="xxnr">
    </textarea>
</div>

<input type="submit" value="发送" />
<input type="reset" value="复位" />
</form>
</body>
</html>

  发布消息处理页面

<?php
session_start();
$xxnr=$_POST["xxnr"];
$jsr=$_POST["jsr"];
$fsr = $_SESSION["yhm"];
$time = date("Y-m-d H:i:s");
include("../DBDA.php");
$db=new DBDA();
$sql="insert into liuyan values(‘‘,‘{$fsr}‘,‘{$jsr}‘,‘{$time}‘,‘{$xxnr}‘,‘未读‘)";
if($db->Query($sql,0))
{
  header("location:fabu.php");	
}

  退出系统页面

退出系统页面是退回登录页面

<?php
session_start();

unset($_SESSION["uid"]);
header("location:Untitled-1.php");

  

 

0526留言板练习

标签:

原文地址:http://www.cnblogs.com/wcc731546227/p/5532747.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!