...

View Full Version : login script / memberspace



neptune1
02-29-2012, 11:09 PM
I tried out this login script and its great http://phpsense.com/2006/php-login-script/ (not spam)

After login how can I create so each user has there own web space? Say if after login I add an image gallery or a file uplaod is there a simple formula to connect the user to there own folders?

mlseim
02-29-2012, 11:22 PM
When a user successfully logs in, a PHP SESSION variable is set ...
$_SESSION['SESS_MEMBER_ID']

So, any other PHP script you have, you can check for the existence of that
SESSION, and you can also know what the user's ID is ... for controlling content.

At the top of any protected, or user-specific page ...



<?php
session_start();

if(isset($_SESSION['SESS_MEMBER_ID'])){
// user is logged-in OK
$memberID=$_SESSION['SESS_MEMBER_ID'];
}
else{
// user is not logged-in, so kick them out ....
header("location: index.php");
exit;
}

// the rest of your script continues on down ...

// query database table .... WHERE memberID='$memberID' ....

// not sure what you call your columns.

?>



.

neptune1
02-29-2012, 11:59 PM
I got it now, thanks. Is there a simple way to assign folders to users?

mlseim
03-01-2012, 01:51 AM
You don't assign any folders (directories).

You save all photos into a directory. If they duplicate a filename,
then append a number to the filename, recheck the filename and then
save it if the filename is unique.

When the photo saves, you add a new row to your MySQL table. That row
has the user's ID, photo filename, title, caption, etc.

Everyone is using the same MySQL table for all of their photos.

When a person logs in, all queries in that table will result in only their photos ..
the rows that have their ID in them.

The file management, user management, everything is controlled by the MySQL tables.

A table for the users,
A table for the photos.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum