## viewscore.
php
<?php
require "config.inc.php";
$pagesize=15;
$sql="select name,score from user";
$temp=mysql_query($sql);
$sum=mysql_num_rows($temp);
$totalpage=ceil($sum/($pagesize*2));
if ($sum==0) {
$totalpage=1;
}
# 分页
if($page<0 or empty($page)){
$page=1;
}
elseif ($page>$totalpage){
$page=$totalpage;
}
$offset=($page-1)*(pagesize*2);
$back_offset=$offset+$pagesize;
$sql="select name,score from user order by score desc limit $offset,$pagesize";
$sql_result=mysql_query($sql);
?>
<html>
<head>
<title>察看积分</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="css/index.css">
</head>
<body bgcolor="#FFFFFF" background="image/bg.gif">
<?php include "header.php";?>
<br>
<table width="100%" border="0" cellspacing="2" cellpadding="0">
<tr>
<td width="50%">
<table width="98%" border="1" cellspacing="0" cellpadding="1" bordercolorlight="#000000" bordercolordark="#FFFFFF" align="center">
<tr bgcolor="#E8E8E8" align="center">
<td bgcolor="#E8E8E8" width="50%">用户名</td>
<td width="50%">积分</td>
</tr>
<?php
while ($sql_row=mysql_fetch_array($sql_result)) {
echo "<tr align="center">";
echo "<td width="50%">$sql_row[name]</td>";
echo "<td width="50%">$sql_row[score]</td>";
echo "</tr>";
}
?> </table>
</td>
<td>
<table width="98%" border="1" cellspacing="0" cellpadding="1" bordercolorlight="#000000" bordercolordark="#FFFFFF" align="center">
<tr bgcolor="#E8E8E8" align="center">
<td width="50%">用户名</td>
<td width="50%">积分</td>
</tr>
<?php
$sql="select name,score from user order by score desc limit $back_offset,$pagesize";
$sql_result=mysql_query($sql);
while ($sql_row=mysql_fetch_array($sql_result)) {
echo "<tr align="center">";
echo "<td width="50%">$sql_row[name]</td>";
echo "<td width="50%">$sql_row[score]</td>";
echo "</tr>";
}
?>
</table>
</td>
</tr>
</table>
<div align="right"> <?php
if ($page!=1){
$backpage=$page-1;
echo"<a href="$php_self?page=1">首页</a> <a href="$php_self?page=$backpage">上一页</a>";
}
if ($page==1){
echo"首页 上一页";
}
if($page!=$totalpage){
$nextpage=$page+1;
echo" <a href="$php_self?page=$nextpage">下一页</a> <a href="$php_self?page=$totalpage">尾页</a>";
}
if($page==$totalpage){
echo" 下一页 尾页";
}
?></div>
<br>
<br>
<?php include "footer.php";?>
</body>
</html>
### vmlogin.php
<?php
require "func.php";
if ($b1) {
if (is_user_exits($name) and check_user_password($name,$password)) {
setcookie ("jl_forum[name]",$name);
setcookie ("jl_forum[password]",$password);
redirect2("viewmsg.php");
}
else {
show_error(4);
}
}
else {
?>
<html>
<head>
<title>main</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="css/page.css">
</head>
<body bgcolor="#FFFFFF" background="image/bg.gif">
<table width="90%" border="1" cellspacing="0" cellpadding="0" align="center" bordercolorlight="#FFCC99" bordercolordark="#FFCC99">
<tr bgcolor="#CCFF99">
<td>
<div align="center"><b>察看留言登陆</b></div>
</td>
</tr>
<tr align="center">
<td>
<form method="post" action="vmlogin.php">
<table width="70%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="38%" align="right">用户名:</td>
<td width="62%" align="left">
<input type="text" name="name" size="17" maxlength="16">
</td>
</tr>
<tr>
<td width="38%" align="right">密码:</td>
<td width="62%" align="left">
<input type="password" name="password" size="17" maxlength="16">
</td>
</tr>
</table>
<input type="submit" name="b1" value="进入">
</form>
</td>
</tr>
<tr bgcolor="#CCFF99">
<td>
<div align="center"><b>论坛信息</b></div>
</td>
</tr>
<tr valign="top">
<td>
<?php include "info.php";?>
</td>
</tr>
</table>
<?php include "footer.php";?>
</body>
</html>
<?php
}
?>
## wrong.php
<?php
switch($id){
case 1:
$msg="非法请求!";
break;
case 2:
$msg="请将表格中标有 "*" 的填写完全";
break;
case 3:
$msg="用户已经存在,请选择其他用户名";
break;
case 4:
$msg="错误的用户名/密码";
break;
case 5:
$msg="两次密码不一样";
break;
case 6:
$msg="您在表格里面填写的数据过长";
break;
case 7:
$msg="无此版面";
break;
case 8:
$msg="无此用户";
break;
case 9:
$msg="您没有输入查询条件";
break;
case 10:
$msg="没有符合查询条件的纪录";
break;
}
?>
<html>
<head>
<title>::: 错误 :::</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="css/page.css">
</head>
<body bgcolor="#FFFFFF">
<?php include "header.php";?><br>
<hr noshade width="95%" size="1">
<div align="center">在处理数据时发生以下错误<br>
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<div align="center"><font color="#FF0000"><?php echo $msg;?></font></div>
</td>
</tr>
</table>
<br>
<a href="javascript:history.back()">点击这里返回</a></div><br>
<br>
<?php include"footer.php";?>
</body>
</html>
############################################################
此程序演示在 edincur.datablocks.net/forum,大家可以去看看效果。
############################################################ |