第七十七天上课 PHP留言板的制作
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第七十七天上课 PHP留言板的制作相关的知识,希望对你有一定的参考价值。
注册界面 ZhuCe.php
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>注册</title> <style> *{margin:0px; padding:0px;} form { position:absolute; left:40%; width:220px; top:100px; } </style> <?php if(!empty($_POST[‘ZhuCe‘])) { if(empty($_POST[‘ZhangHao‘])||empty($_POST[‘MiMa‘])||empty($_POST[‘XingMing‘])) { echo "<script>alert(‘填写的信息不完整‘)</script>"; } else { $ZhangHao=$_POST[‘ZhangHao‘]; $MiMa=$_POST[‘MiMa‘]; $XingMing=$_POST[‘XingMing‘]; include".././ZZ-function/class/UnionDatabase.php"; $db=new unionDatabase(); $sql="insert into YuanGong values (‘$ZhangHao‘,‘$MiMa‘,‘$XingMing‘)"; $result=$db->query($sql); if($result) { echo"<script>alert(‘恭喜您注册成功‘)</script>"; } else { echo"<script>alert(‘注册失败,请检查填写信息‘)</script>"; } } } ?> <form action="" method="post"> <h1 align="center">注册</h1><br> <div>账号: : <input type="text" name="ZhangHao"/></div><br> <div>密码: : <input type="password" name="MiMa"/></div><br> <div>姓名: : <input type="text" name="XingMing"/></div><br> <div align="center"> <input type="submit" value="确认注册" name="ZhuCe" /> <input type="button" value="前去登入" onClick="window.location.href=‘DengRu.php‘"/> </div> </form>
登入界面 DengRu.php
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>登入</title> <style> *{margin:0px; padding:0px;} form { position:absolute; left:40%; width:220px; top:100px; } </style> <?php session_start(); $_SESSION[‘ZhangHao‘]=‘‘; if(!empty($_POST[‘DengRu‘])) { if(empty($_POST[‘ZhangHao‘])||empty($_POST[‘MiMa‘])) { echo "<script>alert(‘账号或密码不能为空‘)</script>"; } else { $ZhangHao=$_POST[‘ZhangHao‘]; $MiMa=$_POST[‘MiMa‘]; include".././ZZ-function/class/UnionDatabase.php"; $db=new unionDatabase(); $sql="select count(*) from YuanGong Where ZhangHao=‘$ZhangHao‘ and MiMa=‘$MiMa‘"; $result=$db->query($sql); if($result[0][0]==1) { $_SESSION[‘ZhangHao‘]=$ZhangHao; header(‘location:main.php‘); } else { echo"<script>alert(‘用户名或密码不存在‘)</script>"; } } } ?> <form action="" method="post"> <h1 align="center">登入</h1><br> <div>账号: : <input type="text" name="ZhangHao"/></div><br> <div>密码: : <input type="password" name="MiMa"/></div><br> <div align="center"> <input type="submit" value="确认登入" name="DengRu" /> <input type="button" value="前去注册" onClick="window.location.href=‘ZhuCe.php‘"/> </div> </form>
主界面 main.php
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>留言板</title> <?php session_start(); if(empty($_SESSION[‘ZhangHao‘])) { header(‘location:DengRu.php‘); } ?> <h1 align="center">留言信息</h1> <table border="1" width="1000px" align="center" bordercolor="#00FF00"> <tr align="center"> <td>发送人</td><td>发送时间</td><td>接收人</td><td>内容</td><td>*</td><td>信息状态</td> </tr> <?php $ZhangHao=$_SESSION[‘ZhangHao‘]; include".././ZZ-function/class/UnionDatabase.php"; $db=new unionDatabase(); $sql="select MingZi from yuangong where ZhangHao=‘$ZhangHao‘"; $MingZi=$db->queryStr($sql); $sql="select * from liuyan where JieShouRen in (‘$MingZi‘,‘所有人‘)"; $result=$db->query($sql); foreach($result as $i) { echo"<tr align=‘center‘> <td>$i[1]</td> <td>$i[3]</td> <td>$i[2]</td> <td>$i[4]</td> <td><a href=‘XiangQing.php?XuHao=$i[0]‘>查看详情</a></td> <td>$i[5]</td> </tr>"; } ?> </table><br> <div align="center"> <a href="FaBuXinXi.php">发布信息</a> <a href="DengRu.php">退出系统</a> </div>
查看详情界面 XiangQing.php
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>留言板</title> <?php session_start(); if(empty($_SESSION[‘ZhangHao‘])) { header(‘location:DengRu.php‘); } ?> <h1 align="center">留言信息</h1> <table border="1" width="1000px" align="center" bordercolor="#00FF00"> <tr align="center"> <td>发送人</td><td>发送时间</td><td>接收人</td><td>内容</td><td>*</td><td>信息状态</td> </tr> <?php $ZhangHao=$_SESSION[‘ZhangHao‘]; include".././ZZ-function/class/UnionDatabase.php"; $db=new unionDatabase(); $sql="select MingZi from yuangong where ZhangHao=‘$ZhangHao‘"; $MingZi=$db->queryStr($sql); $sql="select * from liuyan where JieShouRen in (‘$MingZi‘,‘所有人‘)"; $result=$db->query($sql); foreach($result as $i) { echo"<tr align=‘center‘> <td>$i[1]</td> <td>$i[3]</td> <td>$i[2]</td> <td>$i[4]</td> <td><a href=‘XiangQing.php?XuHao=$i[0]‘>查看详情</a></td> <td>$i[5]</td> </tr>"; } ?> </table><br> <div align="center"> <a href="FaBuXinXi.php">发布信息</a> <a href="DengRu.php">退出系统</a> </div>
发布界面 FaBuXinXi.php
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>发布信息</title> <style> *{margin:0px; padding:0px;} form { position:absolute; left:40%; width:230px; top:100px; } </style> <?php session_start(); if(empty($_SESSION[‘ZhangHao‘])) { header(‘location:DengRu.php‘); } else { if(!empty($_POST[‘FaBu‘])) { if(empty($_POST[‘JieShouRen‘])||empty($_POST[‘NeiRong‘])) { echo "<script>alert(‘接收人和内容不能为空‘)</script>"; } else { $ZhangHao=$_SESSION[‘ZhangHao‘]; include".././ZZ-function/class/UnionDatabase.php"; $db=new unionDatabase(); $sql="select MingZi from yuangong where ZhangHao=‘$ZhangHao‘"; $FaSongRen=$db->queryStr($sql); $JieShouRen=$_POST[‘JieShouRen‘]; $NeiRong=$_POST[‘NeiRong‘]; $ZhuangTai=‘未读‘; $time=date(‘Y-m-d H:i:s‘,time()); $sql="insert into liuyan values(‘‘,‘$FaSongRen‘,‘$JieShouRen‘,‘$time‘,‘$NeiRong‘,‘$ZhuangTai‘)"; $result=$db->query($sql); if($result) { echo"<script>alert(‘发布成功!‘)</script>"; } else { echo"<script>alert(‘发布失败!‘)</script>"; } } } } ?> <form action="" method="post"> <div align="center"> <a href="main.php">查看信息</a> <a href="DengRu.php">退出系统</a> </div><br /> <h1 align="center">发布信息</h1><br /> <div>接收人: <input type="text" name="JieShouRen"></div><br /> <div>内容: <textarea name="NeiRong"></textarea></div><br /> <div align="center"> <input type="submit" name="FaBu" value="确认发布"> <input type="button" value="清空内容"> </div> </form>
以上是关于第七十七天上课 PHP留言板的制作的主要内容,如果未能解决你的问题,请参考以下文章