on 11/11/02 9:01 AM, Warmonkey ([EMAIL PROTECTED]) wrote:

> Hello there,
> 
> My CS clan has just starting using phpBB for our clan forum. We are planning
> to develop a new php based site and wanted to be able to display customised
> content on the main page depending on the user logged in. For instance, I
> was thinking of having a login box in the corner of the page, and once
> logged in, you could navigate to the forum without having to sign in again.

Sessions.  User logs in, if a valid user, you set a session id, and assign a
few variables to that session (session ID is stored on the users computer,
session VARS are stored on the server), like their username.

Then from page to page, you can do simple stuff like

You are logged in as <?=$_SESSION['username']?>


When the user gets to the forum, you can do other stuff:

<?
if(!empty($_SESSION['username']))
    {
    // show the forum
    }
else
    {
    // show login screen
    }
?>


There's a few security issues which a good article will help you work
through, but that's the gist of it!


> Also, because each user has their own profile, I'd like them to be able to
> choose what content/news/announcements they see when they go to the site
> etc. An example of stuff like this in action is CS Nation.

Since you want to tie in with phpBB, you would create a related table to the
user id, which stores some preferences.

let's say phpBB has the following user table:

col names:  userid | password | date_added | firstname | lastname
sample:     justin77 | xxxxxx | 11/11/2002 | Justin | French


then you could RELATE a preferences table to that user table, based on the
userid:

col names:  userid | content | news | announce | color | language
sample:     justin77 | 1 | 1 | 0 | FFCC99 | en


When they log in, you could query the DB, find out these preferences, and
store them as session variables.  Some untested, simplified code:

<?
$sql = "SELECT
        content, news, announce, color, language
        FROM preferences
        WHERE userid='{$_SESSION['username'])'";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);

foreach($myrow as $key => $val)
    {
    if($val)
        {
        $_SESSION[$k] = $val;
        }
    }
?>

Now, for each preference set to 1 (true), you now have a session var with
the same name, set to their preference

On your home page, you could then only display the content they want:

<?
if($_SESSION['content'])
    {
    // display content
    }
?>
<br />
<?
if($_SESSION['news'])
    {
    // display news
    }
?>
<br />
<?
if($_SESSION['announce'])
    {
    // display announce
    }
?>
<br />

This code will of course need a massage to work!!


You could use their favourite colour as the text colour, and customise the
entire display to their preference of language.


It's limitless really!


> Is all this rather ambitious, or can any give some advice/pointers/sources
> of info to go on?

The tricky bit will be integrating with phpBB (which i've never done) OR
getting phpBB to integrate with your own user stuff.



Justin French
--------------------
Creative Director
http://Indent.com.au
Web Developent & 
Graphic Design
--------------------


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to