这篇文章主要为大家详细介绍了PHP简单留言本功能的实现代码,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文实例为大家分享了PHP留言本功能的具体代码,供大家参考,具体内容如下
index.php
$pageCount) //如果输入的页数超过总页数则默认跳转到最后一页 { $currpage=$pageCount; } ?> <title></title> <!--此处添加了bootstrip样式--> <div class="content"> <h5 style="color: red">条留言</h5><br /><ul class="bt"> <li>留言标题</li><li>用户网名</li><li>时间</li></ul> <ul class="nr"> <li></li><li></li><li></li></ul><div class="lynr"> <p><strong>留言内容:</strong></p><span></span></div> <hr style="width:800px" /><ul class="pagination"> <!--上一页--> <?php for($i=1;$i<=$pageCount;$i++) { if($i==$currpage) { echo "<li>«</li>"; } } ?> <!--数字页--> <?php for($i=1;$i<=$pageCount;$i++) { if($i==$currpage) { echo "<li>$i</li>"; }else{ echo "<li>$i</li>";} } ?> <!--下一页--> <?php for($i=1;$i<$pageCount;$i++) { if($i==$currpage) { echo "<li>»</li>"; } } ?> </ul><br /><ul> </ul><hr /><strong style="color:red">发表留言</strong> <table cellpadding="0" cellspacing="0"> <tr> <td>留言标题:</td><td></td></tr><tr> <td>网名:</td><td></td></tr><tr> <td>留言内容:</td><td><textarea name="content" cols="42" rows="5" /></textarea></td></tr><tr> <td></td><td></td></tr></table></div>
conn.php
result.php
<?php error_reporting(0); //关闭NOTICE提示 require_once "conn.php"; $title = $_REQUEST['title']; $username = $_REQUEST['username']; $content = $_REQUEST['content']; $content = str_replace("\n","<br>",str_replace(" "," ",$content)); //显示'空格'和'回车' $week = '星期'.mb_substr( "日一二三四五六",date("w"),1,"utf-8" ); $isok =mysql_query("insert into guestlist(title,username,content,addtime)values('$title','$username','$content','".date("Y-m-d H:i:s")." $week ')"); if($isok) { echo ""; }else { echo ""; } ?>
css/index.css
body{margin:0;padding:0;} ul,li{list-style: none;margin:0;padding:0;} a{text-decoration: none;} .content{ width:800px; margin:0 auto; } .bt{ width:799px; height:20px; text-align: center; background:#EB9316; margin:0 0 5px 0; } .bt>li{ float:left; width:265px; height:20px; text-align: center; line-height: 20px; font-size:13px; } .nr{ float:left; /*如果不浮动 后面的lynr会受影响*/ width:799px; height:20px; text-align: center; background:#B9DEF0; } .nr>li{ float:left; width:265px; height:20px; text-align: center; line-height: 20px; font-size:13<em style="color:transparent">来源[email protected]搞@^&代*@码网</em>px; } .lynr{ float:left; /*如果不浮动会 布局会乱*/ width:800px; margin:1px 0 1px 0; } .content p{ width:70px; height:50px; float:left; } .content span{ display: block; width:710px; float:left; } td{ width:80px; padding:5px 0; /*border: 1px solid #79ABFE;*/ } td input,textarea{ border: 1px solid #79ABFE; } /*tr{ display:block; /*将tr设置为块体元素 显示块状后 就将其包围住了 不是一个矩形了 }*/
dist/css/bootstrap.min.css(自己下载)
效果图:
以上就是PHP简单留言本功能实现代码的详细内容,更多请关注gaodaima搞代码网其它相关文章!