$PAGESIZE=5;
$db=mysql_connect("localhost","root","");
mysql_select_db("lyanban",$db);
$result=mysql_query("SELECT * FROM message order by date desc",$db);
$rowcount=mysql_num_rows($result);
$PAGES=CEIL($rowcount/$PAGESIZE);
if($rowcount==0)
{echo "目前没有留言!欢迎您留言!";}
if($rownum == "")
{
$rownum = 1;
}
$AA=CEIL($rownum/5);
$i=0 ;
echo "
共有留言:$rowcount 条共:$PAGES 页 | ";
姓 名 | $myrow[username] |
电子信箱 | $myrow[email] |
公司主页 | $myrow[homepage] |
留言主题 | $myrow[topic] |
留言内容 | $myrow[content] |
留言时间 | $myrow[date] |
";}
}
echo "
| "; #判断是否有上一页或下一页(10行换页) 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.注册程序
用户注册
如需要ZIP文件可给我来信。tandinet@163.net
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】
相关推荐
- laravel学习教程之存取器
- laravel学习教程之关联模型
- 简单解析PHP程序的运行流程
- PHP预定义变量9大超全局数组用法详解
- composer.lock文件的作用
- PHP编程入门的基本语法知识点总结
- windows8.1下Apache+Php+MySQL配置步骤
- ASP基础知识Command对象讲解
- PHP网站建设的流程与步骤分享
- PHP易混淆知识整理笔记
- php 函数使用方法与函数定义方法
- php for 循环语句使用方法详细说明
- php 输出双引号"与单引号'的方法
- php 获取select下拉列表框的值
- PHP 面向对象 PHP5 中的常量
- PHP 面向对象 final类与final方法
- php empty函数判断mysql表单是否为空
- php+mysql 实现身份验证代码
- PHP初学者常见问题集合 修正版(21问答)
- PHP中基本符号及使用方法


