導航:首頁 > 編程語言 > 留言板php

留言板php

發布時間:2022-02-26 04:11:04

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的留言板

粘貼不上 重復的字元太多了
你可以去搜索一下 網上有很多的源碼站
給你個提示吧 你直接找網吧留言版 就有能滿足你需要的 下載下來 自己看源碼吧

閱讀全文

與留言板php相關的資料

熱點內容
優信二手車解壓後過戶 瀏覽:63
Windows常用c編譯器 瀏覽:780
關於改善國家網路安全的行政命令 瀏覽:835
安卓如何下載網易荒野pc服 瀏覽:656
javainetaddress 瀏覽:106
蘋果4s固件下載完了怎麼解壓 瀏覽:1005
命令zpa 瀏覽:288
python編譯器小程序 瀏覽:946
在app上看視頻怎麼光線調暗 瀏覽:542
可以中文解壓的解壓軟體 瀏覽:595
安卓卸載組件應用怎麼安裝 瀏覽:915
使用面向對象編程的方式 瀏覽:342
程序員項目經理的年終總結範文 瀏覽:932
內衣的加密設計用來幹嘛的 瀏覽:435
淮安數據加密 瀏覽:295
魔高一丈指標源碼 瀏覽:984
松下php研究所 瀏覽:171
c回調java 瀏覽:403
夢幻端游長安地圖互通源碼 瀏覽:747
電腦本地文件如何上傳伺服器 瀏覽:315