您好,登錄后才能下訂單哦!
今天就跟大家聊聊有關怎么在項目中PHP實現一個留言板功能,可能很多人都不太了解,為了讓大家更加了解,小編給大家總結了以下內容,希望大家根據這篇文章可以有所收獲。
HTML代碼
<div class="continer" > <div class="head" ><h3 >PHP留言本</h3></div> <div class="body"> <volist name="guestbook" id="vo"> <div class="panel"> <div class="panel-head" > <span class="nickname" >留言者: {$vo.nickname}</span> <span >|</span> <span class="email" >郵箱: {$vo.email}</span> <span class="time" >時間: {$vo.replytime}</span> </div> <div class="panel-body"> <span class="content">內容: {$vo.content}</span> <span class="time" >{$vo.id}樓</span> </div> </div> </volist> </div> <div class="foot"> <form method="post"> <div class="panel" > <div class="panel-body" > <div class="form-group"> <div class="field field-icon-right"> <input id="nickname" type="text" class="input" name="nickname" placeholder="游客姓名"/> </div> </div> <div class="form-group"> <div class="field field-icon-right"> <input type="text" id="content" class="input" name="content" placeholder="留言內容"/> </div> </div> <div class="form-group"> <span></span> <span class="field"> <input type="text" id="email" class="input" name="email" placeholder="Email"/> </span> </div> <div class="form-group"> <span><button name="liuyan">留言</button></span> <span><button name="restart" onclick="clearDefaultText(this)">重置</button></span> </div> </div> </div> </form> </div> </div> <script> function clearDefaultText(){ var nickname = document.getElementById('nickname'); var content = document.getElementById('content'); var email = document.getElementById('email'); nickname.value=""; content.value=""; email.value=""; } </script>
PHP代碼
public function hierarchicalauthority(){ if(isset($_POST['liuyan'])) { $data['nickname']=$_POST['nickname']; $data['content']=$_POST['content']; $data['email']=$_POST['email']; $data['status']=1; $data['replytime']=date('Y-m-d H:i:s',time()); // print_r($data);die(); $user=M('daili_liuyan_guestbook'); $maxid=$user->max('id'); $data['id']=$maxid+1; $user->add($data); // print_r($_POST);die(); } $guestbook = D('daili_liuyan_guestbook')->select(); $this->assign('guestbook',$guestbook); $this->display(); }
看完上述內容,你們對怎么在項目中PHP實現一個留言板功能有進一步的了解嗎?如果還想了解更多知識或者相關內容,請關注億速云行業資訊頻道,感謝大家的支持。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。