怎么用php做留言本,我的是php+mysql,高手们教教我呗
解决方案 »
- Fckeditor图片上传没问题,但是无法正常显示
- 被hotmail垃圾邮件的问题求助,比较急
- php银灯技术
- 为什么iestore.cn的IESTORE支付时选择Bank wire payment,在按下“I confirm payment”后会出现错误:
- 看下我上传图片的源码那有问题!上传完图片不显示所在目录
- JOOMLA joomla 哪位大哥帮忙看下这两个图片是什么模块实现的
- wordpress图片IE/GOOGLE上能显示 、在ff/opera无法显示,寻求帮助
- 程序逻辑有问题,请大虾帮忙
- CURL之发疯的投票机
- 报错:SourceGuardian Loader不支持PHP5.5.4 ,,怎么办啊~~急!!!
- sns中修改头像后,其他好友页刷新,还是原来的头像!
- 打了一个整合包,大家试试
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="shortcut icon" href="../image/favicon.ico" />
<title>留言板</title>
<style>
.ul{
float:left;
list-style-type:none;
}</style>
<script>
function check()
{
document.getElementById("image").src="code.php?id="+Math.random();
}
function live( l )
{
if(l.txtTitle.value=="")
{
alert('请填写标题!');
return false;
}
if(l.txtContent.value=="")
{
alert('请填写内容!');
return false;
}
return true;
}</script>
</head><body style="font-family:'宋体'; font-size:12px; color:#000;">
<?php
include_once('../conn/conn.php');
$pageSize=3;
$sql1="select count(*) from message where is_pass=1 ";
$rs1=mysql_query( $sql1 );
$count=mysql_result( $rs1,0,0);
if( $count==0)
die ('无留言记录');
$pageCount=ceil( $count/$pageSize );
$currPage=intval( $_GET['page'] );
if ($currPage<1)
$currPage=1;
if( $currPage>$pageCount)
$currPage=$pageCount;
$sql="select M_id, M_title, M_date, M_content, M_reply from message where is_pass=1 limit ". ($currPage-1)*$pageSize .", $pageSize";$rs=mysql_query($sql);?>
<form action="" method="post" name="g_list" id="g_list" ><table width="600" height="165" border="1" cellpadding="0" cellspacing="0">
<tr>
<?php
while( $row=mysql_fetch_array($rs) )
{
?>
<td align="left" valign="middle" bgcolor="#CCFFFF">标题:<?php echo $row['M_title']; ?></td>
</tr>
<tr>
<td align="left" valign="middle">用户名:
日期:<?php echo $row['M_date']; ?></td>
</tr>
<tr>
<td height="76" align="left" valign="middle">内容:<br/><?php echo $row['M_content']; ?></td>
</tr>
<tr>
<td align="left" valign="middle">回复:<?php echo $row['M_reply']; ?></td>
</tr>
<?php
}?>
<tr>
<td height="15"><?php
if ($currPage==1)
{
?>
<ul class="ul"><li>首页 上一页</li></ul>
<?php
}
else
{
?>
<a href="?page=1"><ul class="ul"><li>首页</li></ul> </a>
<a href="?page=<?php echo $currPage-1; ?>" > <ul><li>上一页 </li></ul></a>
<?php
}
?>
<?php
if ($currPage==$pageCount)
{
?>
<ul class="ul"><li>下一页 尾页</li></ul>
<?php
}
else
{
?>
<a style="" href="?page=<?php echo $currPage+1; ?>"><ul class="ul"><li> 下一页</li></ul></a>
<a href="?page=<?php echo $pageCount; ?>" ><ul class="ul"><li> 尾页</li></ul></a>
<?php
}
?><ul class="ul"><li>跳转<select name="selPage" onchange=" location='?page=' + this.value;"></li></ul><?php
for( $i=1; $i<=$pageCount; $i++)
{
if( $i==$currPage)
echo "<option value=$i selected >$i</option>";
else
echo "<option value=$i >$i</option>";
}
?></select>
<ul class="ul"><li>第<?php echo $currPage; ?>页/共<?php echo $pageCount; ?>页 </li></ul></td>
</tr>
</table>
</form>
<br />
<br />
<br />
<br />
<br /><form id="frmBook" name="frmBook" method="post" action="insert.php" onsubmit="return live( this );">
<p>标题:
<input type="text" name="txtTitle" id="txtTitle" />
</p>
<p>内容:</p>
<p>
<textarea name="txtContent" cols="50" rows="5" id="txtContent"></textarea>
</p>
<p>验证码:
<input name="txtcode" type="text" id="txtcode" size="9" />
<img src="code.php?id=<?php echo rand();?>" width="76" height="32" id="image" />
<a href="javascript:check()">看不清换一张</a></p>
<p>
<input type="submit" name="button" id="button" value="留言" />
</p>
</form>
</body>
</html>
PHP100找下,有很多个人完工的练手的,可以参考下
1建立数据库
字段id,留言的人,留言内容,(日期时间)
2程序分两块
1>提交表单;
2>读取数据库把内容返回,你可以在这里加上分页。
基本上就完成了。一张表,不用验证码,用户名的留言板就出来了。
顺带提两句,你可以看看PHP100的视频教程,
开发工具你可以到网上下个APMServ。
建表如#11然后用EasyEcl建一个项目,
然后……然后就木有然后了,直接去PHP100去看视频吧