The downside of your approach is that you'll need to have a different script in each of those six folders so that it defines each user's id differently. This approach doesn't scale well.
Seems to me you should create more than one table. Maybe a table for users that contains a username and password for each of your players. A second table to contain games perhaps. A third table to contain info about which user picked which game.
user
id
username
password
game
id
name
etc.
user_game_picks
id
user_id
game_id
You would need a login form and a game-picking form. Login forms can be pretty simple:
<?php
if (isset($_POST['submit']) {
$errors = array();
if (strlen($_POST['username']) == 0) {
$errors[] = 'No username supplied';
}
if (strlen($_POST['password']) == 0) {
$errors[] = 'No password supplied';
}
if (sizeof($errors) == 0) {
/* check login and redirect on success */
$sql = "SELECT * FROM user WHERE username='" . mysql_real_escape_string($_POST['username']) . "' AND password='" . mysql_real_escape_string($_POST['password']) . "'";
$result = mysql_query($sql)
or die('query failed');
if (mysql_num_rows($result) == 0) {
$errors[] = 'Login failed! No account was found for that username and password';
} else {
// success!
$user_info = mysql_fetch_assoc($result);
session_start();
$_SESSION['logged_in'] = 1;
$_SESSION['user_id'] = $user_info['id'];
$_SESSION['username'] = $user_info['username'];
header('location: game_pick_form.php');
exit();
}
}
}
?>
<form method="post">
username: <input type="text" name="username" value="<?=$_POST['username'] ?>">
password: <input type="password" name="password" value="<?=$_POST['password'] ?>">
<input type="submit" name="submit" value="submit">
</form>
Then in game_pick_form.php, you call session_start() at the top and check for the $SESSION variables. if logged_in is not 1 or if user_id is empty then you force them back to login.
session_start();
if ($_SESSION['logged_in'] !== 1) {
header('location: login.php');
exit();
}
if (empty($_SESSION['user_id'])) {
die('invalid user id');
}
To show only the games which have not been picked, you might use this query:
$sql = "SELECT * FROM games g LEFT JOIN user_game_picks ugp ON ugp.game_id=g.id WHERE ugp.id IS NULL";
I think that will work anyway.