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

案例:简单留言板

时间:2016-06-30 18:24:32      阅读:151      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!