共有留言:$rowcount 条 共:$PAGES 页 现在是第 $AA 页 | ";
echo "
";
while ($myrow=mysql_fetch_array($result)){
$i++;
if(($i>=$rownum)&&($i<$rownum+5)){
echo "";
echo "姓 名 | $myrow[username] |
";
echo "电子信箱 | $myrow[email] |
";
echo "公司主页 | $myrow[homepage] |
";
echo "留言主题 | $myrow[topic] |
";
echo "留言内容 | $myrow[content] |
";
echo "留言时间 | $myrow[date] |
";
echo "
";}
}
echo ""; #判断是否有上一页或下一页(10行换页)
echo ""; echo " | ";
echo "
";
echo "
";
echo "";
?>
2.show.php3(显示程序)
?
$username = htmlspecialchars(ltrim(stripslashes (trim($name))));// 本函式可去掉字串中的反斜线空格字元
$email = htmlspecialchars(ltrim(stripslashes (trim($email))));
$homepage = htmlspecialchars(ltrim(stripslashes (trim($homepage))));
$topic = htmlspecialchars(ltrim(stripslashes (trim($topic))));
$content = htmlspecialchars(ltrim(stripslashes (trim($content))));
// $content=base64_encode($content);
//send email
// if ($ok) mail($email,$topic,$content);
if (($username=="")or($topic=="")or(strlen($username)>20)or(strlen($topic)>20))
{echo "请填写必要的项目或着非法用户名!返回";
}
//wrong email ?
elseif (($email!="")and(!eregi("^[_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3}$",$email)))
{
echo "请您填写正确的 E-Mail 地址返回";
}
//wrong homepage ?
elseif (($homepage!="")and(!eregi("(http://)+[0-9a-z-]+.([0-9a-z-]+.)+[a-z]{2,3}$",$homepage)))
{echo "主页地址输入错误!返回";}
else{
//联接数据库
mysql_connect("localhost","root","");
mysql_select_db("lyanban");
$sql="select password from tb where username='$username'";
$result=mysql_query($sql);
$nums=mysql_num_rows($result);
if($nums!=1){
echo"对不起!请先注册!";
}
else{
//得到日期 YYYY-MM-DD HH:MM:SS 2000-01-01 00:00:00'
$t = date(Y."-".m."-".d." ".H.":".i.":".s);
//将新用户插入数据库
mysql_query("insert into message values ('$username','$email','$homepage','$topic','$content','$t')");
echo "
";
}
}
?>
3.zhuc.php(注册程序)
mysql_connect("localhost","root","")
or die("无法连接数据库,请重试");
mysql_select_db("lyanban")
or die("无法选择数据库,请重试");
$query="select password from tb where username='$username'";
$result=mysql_query($query);
$numrows=mysql_num_rows($result);
if($numrows!=0)
{echo '已有人注册此名,请重新选择名字!返回';}
else
{$query="insert into tb(username,password) values('$username','$password')";
mysql_query($query);
echo '注册成功';
echo '请登录!';}
?>
以下是两个配套的HTML:
1。留言网页
天地网络留言版欢迎您留言!
2.注册程序
登録
<本文 bgcolor="#FFFFFF">