Jump to content

how to let selecter users view a page?


rallokkcaz

Recommended Posts

how to let selecter users view a page?
i don't know how to do the code

here the the code i wanna add the script too.
[code]<?PHP

include ("config.php");

//if the user is not logged in, then redirect to login page.
if (!is_logged_in($user)) {
    header("Location: users.php");  die();
}else{
      include ("header.php");
      //put your code here (protected page).
echo "";
include ("pic_upload.php");
}
?>[/code]
thanks in advanced
Link to comment
Share on other sites

the code you have provided already is a rough sketch of showing a certain page based on whether a user is logged in or not.  the first part:

[code]
if(!is_logged_in($user)) {
  header("Location: users.php"); die();
}
[/code]
calls a function called is_logged_in, passing the variable $user to it. if it returns false, then it redirects you to users.php. if it returns true, it includes your header.php.  So what you need is the is_logged_in function that checks to see if someone is logged in, and oh yeah, the actual login script where someone can login. 
Link to comment
Share on other sites

ok well.. the way the other person was going with the 0, 1, 2, 3 etc...  is global grouplevels.  if you just want lets say two people to view.. then just grab the row IDs of the users you want and put them in an IF statement.  for example..

BELOW WOULD BE PART OF THE MYSQL DATABASE
[table]
[tr][td]USERID[/td][td]USERNAME[/td][/tr]
[tr][td]1[/td][td]Bobby1041[/td][/tr]
[tr][td]2[/td][td]AnUnknownUser[/td][/tr]
[/table]

Then.. make an if statement that just allows the people with those two userids to view it.. and if the userid is different use HEADER to move them to a new page.. or display a message.
> If you need further help please reply or PM me.
Link to comment
Share on other sites

okay, assuming that the rest of your code already works, in the code you originally provided, you have that variable $user, which i'm going to assume is the user's name.  so let's modify your code up there a bit:
[code]
<?PHP

include ("config.php");

//if the user is not logged in, then redirect to login page.
if (!is_logged_in($user)) {
    header("Location: users.php");  die();
}else{
  if ($user != "brad" || $user != "mike") {
      header("Location: users.php");  die(); // or relocate to some other access-denied page
  } else {
      include ("header.php");
      //put your code here (protected page).
    echo "";
    include ("pic_upload.php");
  }
}
?>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.