FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Password protect pages with phpbb





clownFart
I was wondering if there was a mod or a way to protect pages so only members of the forums could enter, or even better members in a sertain group. If not can you just tell me a good way to password a directory, so when so go in it only asks for it once.

thx
hyhy
Yeah i done it in phpBB, just check if the user ID from actual session match any of users ID's in certain group. If not redirect, or just show message that the site cant be viewed.
clownFart
thanks, but i realy dont know anything about php, could you help me a bit more?
hyhy
clownFart wrote:
thanks, but i realy dont know anything about php, could you help me a bit more?


Ok i give you example (i made it for phpBB forums)

Code:
$group_id = groupid;  // enter here your group id 
$user_id=$userdata['user_id'];
   $sql = "SELECT user_id
      FROM " . USER_GROUP_TABLE . " 
      WHERE group_id = $group_id AND user_id = $user_id";
   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, 'Could not obtain user and group information', '', __LINE__, __FILE__, $sql);
   }

   $row = $db->sql_fetchrow($result);

   if ( $row['user_id'] != $userdata['user_id'])
          {
          die("You Are Not In That Group!");
          }

This text can only be seen for members from certain group.


Well i advice you to learn about php and mysql if you want to change / upgrade / make scripts. There's so many tutorials in internet, and many you can learn in just one day.
clownFart
Thank you very much for your help. I've put your code in my page and got a couple of errors, I'm pretty sure I fixed them. Now I get this error:

Fatal error: Call to a member function on a non-object in /home/clownfar/domains/cwa.frih.net/public_html/forums/mo.php on line 326

Code:

<?php
$group_id =-CWA- Clan; // enter here your group id
$user_id=$userdata['user_id'];
   $sql = "SELECT user_id
      FROM " . USER_GROUP_TABLE . "
      WHERE group_id = $group_id AND user_id = $user_id";
   if ( !($result = $db->sql_query($sql)) )                                //LINE 326
   {
      message_die(GENERAL_ERROR, 'Could not obtain user and group information', '', __LINE__, __FILE__, $sql);
   }

   $row = $db->sql_fetchrow($result);

   if ( $row['user_id'] != $userdata['user_id'])
          {
          die("You Are Not In That Group!");
          }

echo "This text can only be seen for members from certain group.";
?>
Related topics
How to password-protect content?
How do i password protect a web page using html
How to password protect windows directories?
Password Protect a Folder
How to password protect a zip file
Passwords?
free .net re-directs?
A BUNCH OF FREE DOMAINS ALL HERE!!!!
Password Protect my site
Password Protected pages
htaccess Password Protection
Password Protecting Directories?
Two questions
private HTML
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.