今天就跟大家聊聊有关怎么在项目中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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。