php制作留言板
㈠ 求一步一步教php留言板制作方法
1. 先设计数据表,一般留言板需要两个表:留言内容表、回复表
留言内容表:messages
字段如下:
id 自动增加
contents 留言内容
messages_time 留言时间
回复表:reply
字段如下:
id 自动增加
messages_id 关联messages表的id
contents 回复的内容
reply_time 回复时间
2. 设计留言板页面及保存留言数据
大概代码如下:
<form name="form1" method="post" action="index.php?action=ok">
<texarea cols="30" rows="10" name="contents">
</textarea>
<input type="submit" value="提交">
</form>
<?php
if($_GET['action'] == 'ok'){
$contents = $_POST['contents'];
mysql_query("insert into messages values(NULL,'".$contents."',now())");
}
?>
3. 显示留言内容,遍历数据表
<?php
//包含数据连接代码
require('data.php');
$query = mysql_query("select * messages");
while($array = mysql_fetch_array($query)){
echo $array['contents']."<br>";
}
?>
4. 回复的设计可以参照留言的设计
㈡ 使用PHP脚本制作一个简单的留言板、跪求教程!!
下载软件 XMPP === 用途:搭建php环境
系统 貌似现在的电脑基本上都能实现,除非你的回电脑很老很老
安装万答软件后浏览器输入localhost/phpmyadmin
1、建立留言数据表
2、建立留言字段
->留言内容
->留言作者
->留言时间
3、写php代码和写html页面实现留言
(2)php制作留言板扩展阅读是PHP教程,不懂的可以去多看看,不是一言两语就能说清楚的
㈢ php留言板的回复怎么做
首先得设计好数据库,留言一个表,回复一个表,然后把留言表中关键内字ID关联到回复表中容。
比如:
留言表:message
id
contents
user
time
回复表:reply
id
m_id 关联留言表中的id
contents
user
time
然后程序方面把对应的留言、回复保存到相应的表中,读取的时候先遍历留言表,然后通过留言表id再读取对应的回复数据。
㈣ 如何用php做出登陆注册留言板
用php做出登陆注册留言板:
<form id="form1" name="form1" method="post" action="<?php echo site_url()."/publish/user_message"?>">
<textarea rows="5" cols="50" name="huifu" <?php if($uere_name == "0"){echo "disabled";}?> >
<?php
if($uere_name == "0")
{echo "抱歉你还没登录不能进行留言";}
?>
</textarea>
<input class="wole" name="author" value="<?php echo $author;?>" /><!--接受方帖子作者-->
<input class="wole" name="news_id" value="<?php echo $news_idx;?>" /><!--文章id-->
<input type="submit" name="Submit"/>
</form>
<script language="javascript">
function updateinfo(){
if(<?php echo $uere_name;?> == 1){
document.form1.Submit.value = "留言";
document.form1.Submit.disabled = false;
}
else{
document.form1.Submit.value = "还未登录";
document.form1.Submit.disabled = "disabled";
}
}
updateinfo();
</script>
回复帖子:
<p>这里是<?php echo $is;?>楼 用户:<?php echo $sel->receiver_author;?> <br />留言内容:<?php echo $sel->content?>
<a onClick="showdiv('contentid<?php echo $is;?>','showtext<?php echo $is;?>')" href="javascript:void(0)">回复</a>
<div id="contentid<?php echo $is;?>" class="none">
<?php
$query = $this->db->query("select * from message where son_id ='$sel->id' order by id");//获取指定父id的子回复
$revis = $query->result();
foreach($revis as $row){?>
<p><?php if($row->sender_author == $row->receiver_author){echo $row->sender_author;}
else{ echo $row->sender_author."回复了:".$row->receiver_author;}?>
内容是:<?php echo $row->content?></p>
<?php }?>
<form action="<?php echo site_url()."/publish/son_message"?>" method="post">
<input name="son_idx" class="wole" value="<?php echo $sel->id?>" />
<input name="receiver_author" class="wole" value="<?php echo $sel->receiver_author;?>" />
<input class="wole" name="news_id" value="<?php echo $news_idx;?>" /><!--文章id-->
<textarea rows="5" cols="50" name="huifux"></textarea>
<br><input type="submit" name="sub" value="回复"></form></div></p>
<script language="JavaScript" type="text/JavaScript">
<!--
function showdiv(targetid,objN){
var target=document.getElementById(targetid);
var clicktext=document.getElementById(objN)
if (target.style.display=="block"){
target.style.display="none";
clicktext.innerText="回复";
} else {
target.style.display="block";
clicktext.innerText='收起';
}
}
-->
</script>
效果图:
㈤ 想写个PHP留言板,请问要怎么做
1. 先设计数据表,一般留言板需要两个表:留言内容表、回复表
留言内容表:messages
字段如下:
id 自动增加
contents 留言内容
messages_time 留言时间
回复表:reply
字段如下:
id 自动增加
messages_id 关联messages表的id
contents 回复的内容
reply_time 回复时间
2. 设计留言板页面及保存留言数据
大概代码如下:
3. 显示留言内容,遍历数据表
4. 回复的设计可以参照留言的设计
㈥ php+mysql做留言板
shouye.php
?php
include"conn.php";
$sql="select*fromroomsorderbyid";
$query=mysql_query($sql);
while($row=mysql_fetch_array($query)){?>
<ahref="message.php?id=<?phpecho$row["id"]?>"><?phpecho$row["name"];?></a>
<?php}?>
messages.php
<?php
$room_id=$_GET["id"];
include"conn.php";
echo"<br>";
if(isset($_POST["sub"])){
$hid=$_POST["hid"];
$content=$_POST["content"];
$sql="insertintomessages(room_id,content,sent_at_datetime)values('".$hid."','".$content."','".time()."')";
$query=mysql_query($sql);
$sql_rooms="select*fromroomswhereid!='".$hid."'";
$query=mysql_query($sql_rooms);
while($row=mysql_fetch_array($query)){
?>
<ahref="message.php?id=<?phpecho$row["id"]?>"><?phpecho$row["name"];?></a>
<?php
}
}
$sql_mess="select*frommessageswhereroom_id='".$room_id."'";
$query=mysql_query($sql_mess);
while($row=mysql_fetch_array($query)){?>
<?php
$date=$row["sent_at_datetime"];
echo$row["content"]?> <?phpechodate("Y-m-dH:i:s",$date+8*60*60);echo"<br>";?>
<?php}?>
<formmethod="post"action="message.php">
<inputtype="textarea"name="content">
<inputtype="hidden"name="hid"value="<?phpecho$room_id?>">
<inputtype="submit"name="sub"value="留言">
</form>
时间好像是不对,水平拙劣,希望能帮到你,共同进步!!!
㈦ 用PHP怎么做留言板
我来教你:
首先你要建立一个mysql数据库
然后在数据库里面设置字段 例如 用户 留言
当你在html页面的文本框填写留言后,用表单点击提交(在表单里面要设置提交到那个页面 比如:index.php)
当你提交到改页面后,在这个页面填写你的php代码
就是连接数据库,然后将你的留言写进数据库
最后查看 和删除 就是执行数据库常见的查询功能和删除功能了
㈧ PHP+mysql做一个留言板
先select 你的留言板 内容 送入数组 result
然后循环for($i=0;$i<count($result);$i++){$result[$i]['question_no'] = $i+1;} 然后前台调foreach循环的 question_no 只有思路 具体你要自己写
第二个问题 问错了 如果循环对的话 和 div 对应的话 不会出错的 你要自己检查你是否写对没
㈨ php留言板制作
你确定你的标点符号是对的?
比如:
$title=$_POST[`title`];
$con=$_POST[`con`];
还有标题<inputtype=`text`size=20name="title"value="<?phpecho$rs[`title`]"><br>
内容<textarearows="5"cols="50"name="con"><?phpecho$rs[`contents`]></textarea><br>
你再确定你的变量引用是正确的?
比如:set`title`='title'
大哥,你的语法错得不得了啊?
你不但没有php的基础,连html的基础都没有
标点符号都用不对!
主要体现在引号和反引号上!
<?php
include_once'conn.php';
$Sub=$_POST['submit'];
if(!empty($Sub)){
$title=$_POST['title'];
$con=$_POST['con'];
$sql="update`liuyanban`set`title`='{$title}',`content`='{$con}'";
echomysql_query($sql)?'ok':mysql_error();
}
?>
<formaction="add.php"method="post">
标题<inputtype="text"size=20name="title"value="<?phpecho$rs['title']"/><br/>
内容<textarearows="5"cols="50"name="con"><?phpecho$rs["contents"];?></textarea><br>
<inputtype="submit"name="submit"value="发布留言"/>
</form>
㈩ 如何用php做留言板。
<!-- 表单-->
<form method="post" action="本页" >
<input type="表单元素" name="重要">
其他的表单略过这里只讲原理
</form>
<$conn=mysql_connect ("服务器",用户,密码);
$mysql_select_db=“数据库”;
$a=$_post[重要];
.
.
.
把上面表单中的元素全部获取。
$query="insert into 表名(字段1,字段2.。。。) value($a,$b........)";
mysql_query($query);
>
以上是主要过程。中间还有表单验证没有添加