I have started work on a site. It is a members only site which is run using sessions. What I want to be able to do is show at the top of my page a counter of the people currently logged in and a list of their names, like the at the top of each of these forums. Here is the script. can someone please show me an example of how to accomplish this, thanks.
<?php
include("config.php");
$connect = mysql_connect("$user_hostname", "$user_username", "$user_password");
mysql_select_db("$user_database", $connect);
session_start();
if(!isset($username)) {
echo "<form method=\"POST\" action=$PHP_SELF>
<center>
<table>
<tr>
<td>Username:</td>
<td><input type=\"text\" name=\"username\" size=\"20\"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type=\"password\" name=\"password\" size=\"20\"></td>
</tr>
<tr>
<td colspan=\"2\">
<p align=\"center\"><input type=\"submit\" value=\"Submit\" name=\"submit\"></td>
</tr>
</table>
</center>
</form></br>
If you aren't a member please click <a href=\"personal_information.php\">here</a> to register.";
exit;
}
session_register("username");
session_register("password");
$sql = "SELECT * FROM user_information WHERE username = \"$username\" AND password = \"$password\"";
$result = @($sql) or die("No.");
if(mysql_num_rows($result) == "0") {
session_unregister("username");
session_unregister("password");
echo "<h2 align=center>Wrong username and password, try again</h2>";
exit;
}
$username = mysql_result($result,0,"username");
$firstname = mysql_result($result,0,"firstname");
$lastname = mysql_result($result,0,"lastname");
$email = mysql_result($result,0,"email");
$city = mysql_result($result,0,"city");
$dob = mysql_result($result,0,"dob");
$msn = mysql_result($result,0,"msn");
$yahoo = mysql_result($result,0,"yahoo");
$telephone = mysql_result($result,0,"telephone");
$gender = mysql_result($result,0,"gender");
$profile = mysql_result($result,0,"profile");
mysql_close($connect);
?>