Jump to content


Photo

how to let selecter users view a page?


  • Please log in to reply
13 replies to this topic

#1 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 24 August 2006 - 04:38 AM

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.
<?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");
}
?>
thanks in advanced

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 24 August 2006 - 04:43 AM

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:

if(!is_logged_in($user)) {
   header("Location: users.php"); die();
}
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. 

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 24 August 2006 - 04:48 AM

ok ive got the whole thing
a login , register, and forgot password page.

but they are all within the page users.php

so it goes like

users.php?maa=register
ect.

thats the login page


#4 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 24 August 2006 - 04:50 AM

so then what's the problem? the code you have provided, assuming that your function works and your variables are being passed right, etc.. should work.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#5 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 24 August 2006 - 05:00 AM

i don't have a problem

i need a script that only allows certain user to view it

(example) say i only want user1 and user2 to view page.php
so user3 can't look at the page.

get my drift now? ???

#6 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 24 August 2006 - 05:03 AM

well, you could add a userlevel field for your users. a simple integer field that holds for instance  0,1,2, etc.. and check the user's level. if they aren't high enough, then they don't get to view the page.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#7 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 24 August 2006 - 05:14 AM

how do i do that?


#8 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 24 August 2006 - 05:24 AM

ok i don't want like 1 2 3
stuff i just want to allow 2 users to view this one page!

#9 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 24 August 2006 - 05:31 AM

two specific users and nobody else? just check for their username.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#10 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 24 August 2006 - 05:32 AM

how do i do that!  ???
and thanks for all the help! ;)

#11 kickindrummerkid

kickindrummerkid
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 24 August 2006 - 05:34 AM

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




USERIDUSERNAME
1Bobby1041
2AnUnknownUser


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.

#12 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 24 August 2006 - 05:40 AM

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:
<?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");
   }
}
?>

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#13 rallokkcaz

rallokkcaz
  • Members
  • PipPipPip
  • Advanced Member
  • 194 posts
  • LocationSomewhere, CA (Cactus Area)

Posted 24 August 2006 - 05:48 AM

ok that doesn't work
no matter who im logged in as it automaticly
redirects me to users.php

help!!

#14 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 24 August 2006 - 05:49 AM

first off, did you change "mike" and "brad" to the correct user names? 2nd, try echoing $user to see what it is holding.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users