1. 用php怎么做留言板
我来教你:
首先你要建立一个mysql数据库
然后在数据库里面设置字段 例如 用户 留言
当你在html页面的文本框填写留言后,用表单点击提交(在表单里面要设置提交到那个页面 比如:index.php)
当你提交到改页面后,在这个页面填写你的php代码
就是连接数据库,然后将你的留言写进数据库
最后查看 和删除 就是执行数据库常见的查询功能和删除功能了
2. php建立留言板问题
Notice是提示级别,不算出错,不影响程序正常运行,你可以在php.ini文件中配置error_reporting项将其关闭,也可以在代码中加入
@error_reporting(E_ALL & ~E_NOTICE);来屏蔽。
Undefined variable指的是变量未声明。有php中变量是不用声明就可以直接使用的,所以只是Notice,而不是Error或者warning
想用更规范的编程风格就先声明变量吧。
这里$_POST是客户端传来,不便事先申明,规范的写法是先判断变量是否存在再引用,就不会有这个提示了,常见的写法如下:
$user=isset($_POST['user'])?$_POST['user']:'';
当然,这里还应该做更多的判断,对变量进行过滤。
你这样直接传入SQL有严重的安全隐患。
3. php留言板的回复怎么做
首先得设计好数据库,留言一个表,回复一个表,然后把留言表中关键字ID关联到回复表中。
比如:
留言表:message
id
contents
user
time
回复表:reply
id
m_id 关联留言表中的id
contents
user
time
然后程序方面把对应的留言、回复保存到相应的表中,读取的时候先遍历留言表,然后通过留言表id再读取对应的回复数据。
4. PHP+mysql做一个留言板
先select 你的留言板 内容 送入数组 result
然后循环for($i=0;$i<count($result);$i++){$result[$i]['question_no'] = $i+1;} 然后前台调foreach循环的 question_no 只有思路 具体你要自己写
第二个问题 问错了 如果循环对的话 和 div 对应的话 不会出错的 你要自己检查你是否写对没
5. 如何用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>
效果图:
6. 怎样制作php留言板的回复
既然ID 能传送过去 那content 你就不能传送么?
这个为什么用GET传 应该用POST传。。
大概这样 你每条留言后面都有一个回复连接
点击这个连接跳转到回复页面 把这个留言的ID GET传递过来。。
在回复页面有一个textarea文本域 还有一个hidden 用来放置传过来的ID
然后你在textarea里面添加好回复内容后 点击submit按钮提交 POST提交啊
然后在处理页面进行数据库添加 .这样还不明白么?
---------------------------------------------------------
随你便 你想显示就显示出来 你就用text 不用hidden 不过 到现在未知 我没有见过一个把id显示出来的 。。 难道对于你来说用了hidden有什么问题么?
7. 求php语言编写的留言板源码!!!!!!!!!
这是一个简单的留言本,目前还没有后台管理程序。如果哪位高手能补上,那就太好了。
演示在http://www.ideawu.net/person/liuyan
留言保存在message.txt文件中,留言的格式为:date<$>ip<$>name<$>content
"<$>"为分隔符号
注意:源码文件和message.txt文件必须以gbk格式保存。如果你不知道如何保存文件为gbk格式,请咨询你的文本编辑器软件提供商。
/****************************************
* 本代码可以用作任何用途,但是与作者无关。
* 也就是,你使用本代码获取收益或者因此受
* 到损害,后果与作者无关。
****************************************/
file: index.php
代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>留言板</title>
<link rel="stylesheet" href="../msg.css" type="text/css">
</head>
<body>
<br><B><FONT COLOR="#0000FF">图片留言板</FONT></B>
<center>
<table width="800" border="1" bordercolor="#88CCEE" cellspacing="0" cellpadding="4" style="border-collapse:collapse; word-break:break-all">
<tr><td style="border-right-style: none">
<form method="post" action="savemsg.php" style="font-size: 13px">
姓名:<br><input type="text" name="guest_name" maxlength=32 size=32><br>
留言:(字数:<font color="#0000FF"><span id=sNum>0</span></font>/256)<br>
<textarea class="textForm" name="guest_msg" cols="64" rows="8" onkeyup="sNum.innerHTML=this.value.length"></textarea><br>
<input class="button" type="submit" name="submit" value="发表留言">
<input class="button" type="reset" value="重置" name="reset">
</form>
</td></tr>
</table>
<?php
include("showmsg.php");
if(!empty($_GET['p'])){
$num=$_GET['p'];
showpage($num);
}else showpage(1);
?>
</center>
</body>
</html>
file: showmsg.php
代码:
<?php
function showpage($p)
{ ?>
<table width="800" border="0" bordercolor="#88CCEE" cellspacing="0" cellpadding="4" style="border-collapse:collapse; word-break:break-all;font-size:12px;">
<tr><td>
<p style="line-height: 100%; margin-top: 1; margin-bottom: 1" align="left">
<?php
$perPage=7; //每页显示留言数目
$num=$p;
if($num<1) $num=1;
$prev=$num-1;
$next=$num+1;
$page=$num-1; //当前页码
$fname="message.txt"; //存储留言的文件
$all_msg=file($fname); //将留言读入数组
$line_count=count($all_msg);
$page_count=ceil($line_count/$perPage);
if($prev>0)
echo "<a href=index.php?p=$prev>上一页</a>";
else
echo "上一页";
if($line_count>($next-1)*$perPage)
echo "<a href=index.php?p=$next>下一页</a>";
else
echo "下一页";
echo "当前第 ".$num." 页,共有".$page_count."页,".$line_count."条留言。";
?>
</p></td></tr>
</table>
<table width="800" border="1" bordercolor="#88CCEE" cellpadding="3" cellspacing="0" style="border-collapse:collapse; font-size:12px; word-break:normal; table-layout:fixed;">
<tr height="18" bgcolor="#5FBEF8"><td width="20%">
<b>留言时间/留言者</b></td><td width="86%"><b>留言内容</b>
</td></tr>
<?php
//显示留言
$bg1="#FBF9F9"; $bg2="#E9EFF4";$bg=$bg2;
for($n=$line_count-1-$page*$perPage;$line_count-1-$page*$perPage-$n<$perPage;$n--){
$bg=($bg==$bg1)? $bg2:$bg1; //变换背景颜色
if(!empty($all_msg[$n])){
list($date,$ip,$name,$msg)=explode("<$>",$all_msg[$n],4); //获取留言内容
echo "<tr bgcolor=$bg>";
echo "<td width=14%>".$date."<br><b>".$name."</b></td>";
echo "<td width=86%>".$msg."</td>";
echo "</tr>";
}
}
?>
</table>
<table width="800" border="0" bordercolor="#88CCEE" cellspacing="0" cellpadding="4" style="border-collapse:collapse; word-break:break-all;font-size:12px">
<tr><td>
<p style="line-height: 100%; margin-top: 2; margin-bottom: 2" align="left">
<?php
if($prev>0)
echo "<a href=index.php?p=$prev>上一页</a>";
else
echo "上一页";
if($line_count>($next-1)*$perPage)
echo "<a href=index.php?p=$next>下一页</a>";
else
echo "下一页";
echo "当前第 ".$num." 页,共有".$page_count."页,".$line_count."条留言。";
?>
</p></td></tr>
</table>
<?php } ?>
file: savemsg.php
代码:
<?php
$MSG_MAX_LEN=512; //留言最大长度
if (getenv("HTTP_CLIENT_IP"))
$ip= getenv("HTTP_CLIENT_IP");
elseif (getenv("HTTP_X_FORWARDED_FOR"))
$ip= getenv("HTTP_X_FORWARDED_FOR");
else
$ip= getenv("REMOTE_ADDR");
//获取IP地址结束
$date=date("Y年m月d日 H:i:s",time());
if(empty($_POST['guest_name']))
die("请填你的名字。<a href=index.php>Refresh</a>");
if(empty($_POST['guest_msg']))
die("请填写留言内容再提交。<a href=index.php>Refresh</a>");
$guest_name=strip_tags($_POST['guest_name']);
$guest_msg=substr($_POST['guest_msg'],0,$MSG_MAX_LEN);
//write message to file
//make the message be a line when stored
$guest_msg = str_replace( "\r\n", "\n", $guest_msg);
$guest_msg = str_replace( "\r", "\n", $guest_msg);
$guest_msg = str_replace(" "," ",$guest_msg);
$guest_msg = str_replace(">",">",$guest_msg);
$guest_msg = str_replace("<","<",$guest_msg);
$guest_msg = str_replace("\'","'",$guest_msg);
$guest_msg = nl2br($guest_msg);
//保存留言,以追加的形式
$fname="message.txt";
$fp=fopen($fname,"a+");
fwrite($fp,$date."<$>".$ip."<$>".$guest_name."<$>".$guest_msg."\n");
fclose($fp);
echo "<meta http-equiv='refresh' content='0;url=index.php'>";
?>
用于显示效果的样式表文件
file: msg.css
代码:
A:link {
color: #0033FF;
text-decoration: none;
}
A:visited {
color: #0033FF;
text-decoration: none;
}
A:hover {
color: #30A300;
text-decoration: underline;
}
A:active {
color: #0036A9;
text-decoration: none;
}
BODY{
font-family: Verdana,Arial,Helvetica,sans-serif;
font-size: 12px;
background: #FBF9F9;
}
TABLE{
font-family: Verdana,Arial,Helvetica,sans-serif;
font-size: 12px;
border-collapse: collapse;
table-layout: fixed;
margin: 0px;
}
8. 用PHP完成留言板功能
留言表:留言ID、用户ID、内容、发表时间、修改时间(此字段可选)。
回复表:回复ID、留言ID、用户ID、内容、发表时间、修改时间(此字段可选)。
第一个用户ID是谁发表的留言,第二个用户ID是谁回复的留言,这样无限回复没问题,应该和你设计的差不多。
查询(查询某条留言的所有回复):
在回复表里查询所有该留言的回复记录(查询条件为留言ID),并按发表时间降序
回复内容表:
回复Id 回复内容
回复关联表:
回复内容id 回复内容id
已私信
9. php留言板中怎么删除
首先在留言详情的后面添加一个标签
<a href="/localhost/message/delete?id=<?=$item->id?>">删除</a>
就是点击到这个删除,就会传递一个留言的id值到相应的页面
然后在该页面执行数据库操作 delete ( 'tablename' ,'id'=$id);
写SQL语句就行了
publicfunctiondelete()
{
//我这写的是MVC模式下的
$id=$this->input->get('id',TRUE);//get方法获取链接后的id值
$this->db->where('id',$id);
$this->db->delete('list');
//
}
10. 如何制作PHP+MySQL的留言板
粘贴不上 重复的字符太多了
你可以去搜索一下 网上有很多的源码站
给你个提示吧 你直接找网吧留言版 就有能满足你需要的 下载下来 自己看源码吧