首页 > 其他 > 详细

案例:简单留言板

时间:2016-06-30 18:21:26      阅读:227      评论:0      收藏:0      [点我收藏+]

技术分享

主页代码:

<style type="text/css">
*{
    margin:0px;
    padding:0px;
    }

#a{
    margin:10px auto;
    width:300px;
    height:100px;
    }
#b{
    border:#000 1px solid;
    width:300px;
    height:100px;
    margin:10px auto;
    }
#aa{
    width:300px;
    height:100px;
    }
</style>
</head>

<body>
<br />
<br />
<br />
<h1 align="center">留言板</h1>
<div id="b">
<?php
session_start();
include ("../DBDA.php");
$dx=new DBDA();
$sql="select * from liuyan where uid=‘{$_SESSION[‘uid‘]}‘";
$attr=$dx->Query($sql);
foreach($attr as $v)
{
    echo "<div><span>留言者:{$v[1]}</span>
    <span>留言信息:{$v[2]}</span>
    <span>留言时间:{$v[3]}</span>
    </div>";
}
?>
</div>
<div id="a">
<form action="chuli.php" method="post">
请输入留言:<input type="text" id="aa" name="text"/>
<input type="submit" value="提交"/>
</form>
</div>
</body>

处理页面:

<?php
session_start();
$_SESSION["uid"]="yonh";
include ("../DBDA.php");
$text=$_POST["text"];
$uid=$_SESSION["uid"];
$time=date("y-m-d H:i:s");
$dx=new DBDA();
$sql="insert into liuyan values(‘‘,‘{$uid}‘,‘{$text}‘,‘{$time}‘)";
//除了bool型和数字型不加‘‘,都加‘‘
$re=$dx->Query($sql,0);
if($re)
{
    header("location:test.php");
    }
else
{
    echo "留言失败!";
    }

 

案例:简单留言板

原文:http://www.cnblogs.com/jinshui/p/5630587.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!