Hello,
I have started creating a system which users need to log in. But im having problems (once the user has logged in) getting the next pages to recognise who has logged in. Does anyone know how I can pass the UserID Information to the next page? Ive been told i have to use sessions. How do I do this?
Thanks
Keeping a record on users IDs
Moderator: General Moderators
sessions, or database managment is one of 2 ways to do this.
one way is via the following code :
that's one way at least...
one way is via the following code :
Code: Select all
<?php
// say we have a database named Bob with a table of Users
//In that table, we have the fields : user, userid, password, loggedin
mysql_connect('localhost','username','password');
mysql_select_db('Bob');
$user = array();
$sql = "Select user from users where logged_in = '1'";
$result = mysql_query($sql) or die(Mysql_error());
while ($row = mysql_fetch_array($result))
{
$user[] = $row['user'];
}
// now, let's say that we want to display this info on the page :
echo 'The Following Users are Logged on : ';
for($i=0; $i<=count($user); $i++)
{
echo $user[$i].'<br/>';
}
?>