dtamho6404 2012-07-12 13:21
浏览 9
已采纳

只有具有一定等级的成员才能看到页面

In my members database I have a section called rank.

Basically what im trying to do is make certain pages viewable to members with a rank higher than 12 for example, and if the rank is lower than 12 then they are redirected back to the home page. (obviously their will be lots of different pages for rank 5+ members, Rank 7+ members, rank 20+ members etc)

Can anyone help me with a tutorial or something please?

I did ask for help earlier with my current code, but I dont think that code is ever going to work, Ive been changing it and playing with it for a week now and can not possibly see any other ways to get it to work Members Rank only area's

I am still learning php, So ideally a nice easy explaining tutorial would be nice.

Database:

id int(11) 
username varchar(200) latin1_swedish_ci 
password varchar(216) latin1_swedish_ci 
security varchar(200) latin1_swedish_ci 
email varchar(216) latin1_swedish_ci 
ip varchar(200) latin1_swedish_ci 
rank varchar(216) latin1_swedish_ci 
name varchar(30) latin1_swedish_ci 
age varchar(40) latin1_swedish_ci 
gender varchar(40) latin1_swedish_ci 
location varchar(40) latin1_swedish_ci 
helpfaerie int(11) 
profile text latin1_swedish_ci 
about text latin1_swedish_ci 
tasks text latin1_swedish_ci 
joined varchar(216) latin1_swedish_ci 
laston int(200) 
icedmutereason text latin1_swedish_ci 
icedmutedetails text latin1_swedish_ci 
icedmuteby varchar(200) latin1_swedish_ci 
icedmutedate int(200) 
posts int(11) 
signature varchar(216) latin1_swedish_ci 
avatar varchar(216) latin1_swedish_ci 
neohtml text latin1_swedish_ci 
siggy text latin1_swedish_ci 
verify int(11) 
changedpass int(1)

Header.inc.php

<?php 

include ($_SERVER['DOCUMENT_ROOT'].'/dblink.php'); 
include ($_SERVER['DOCUMENT_ROOT'].'/addon.php'); 

$geterror= $_GET['error'];

$error= stripplus($geterror);

$extra = mysql_fetch_array(mysql_query("SELECT * FROM extra WHERE id='1'"));


$cp = mysql_fetch_array(mysql_query("SELECT * FROM members WHERE username = '$username'"));



$weather = $extra[weather];
$wurl = $extra[wurl];
$games = $extra[games];
$xword = $extra[xword];
$xword2 = $extra[xword2];
$xworddate = date("M j Y",$extra[xworddate]); 
$userinfo = mysql_fetch_array(mysql_query("SELECT * FROM members WHERE username='$username'"));
$rank = $userinfo[rank];




if (!$checkrank) { $checkrank = 0; }
if (!$rank) { $rank = 0; }
if (!$rank == ' ') { $rank = 0; }
if ($rank < $checkrank)
{

     header("Location: $baseurl/index.php?error=You+can+not+view+this+page.");
}




if ($rank >= 30)
{

    $admin = "<a href=\"$baseurl/staff/admin.php\">Admin</a>";
}


if ($username)
{

mysql_query("UPDATE members SET laston = $timestamp+120 WHERE username='$username'");

mysql_query("UPDATE members SET ip = '$ip' WHERE username='$username'");

    $login = "Welcome $username :) <a href=\"$baseurl/logout.php\" >Logout</a>";

$helpfaerie = "<a href=\"$baseurl/helpfaerie.php\" >Help Faerie</a>";

}

else
{
$login = "<form name=\"login\" action=\"$baseurl/login.pro.php\" method=\"post\"  > <input type=\"hidden\" name=\"act\" value=\"doLogin\" color=\"#000000\" valign=\"middle\" >&nbsp;Username: <input type=\"text\" name=\"username\" color=\"#000000\"  style=\"width:100px; height:20px;font-size:10px;\">
Password: <input type=\"password\" name=\"password\"  style=\"width:100px; height:20px;font-size:10px;\"> <input type=\"submit\" name=\"submit\" value=\"Login\" style=\"width:42px; height:20px;font-size:10px;\"></form>";


}


ECHO <<<END

and then the font.php

<?php
$pagetitle = "Add Font";





session_start();

// Rank Limit
       $limit = 10;

        // Using a session 
    $rank = $_SESSION['rank'];

       // Using a cookie
       $rank = $_COOKIE['rank'];

    if ($rank < $limit) {
        header("$baseurl/index.php?error=You+can+not+view+this+page.");
        exit();
        die();
    }


include ($_SERVER['DOCUMENT_ROOT'].'/staff/header.inc.php');


ECHO <<<END
  • 写回答

2条回答 默认 最新

查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?