ive got a script where someone logs in with their username, and password. now im having trouble because when they go from one page to the next, their own information(such as their real name), isn't showing up, instead some other members info is. so im trying to use sessions so that their information will show up. so far i have been successful, except i never closed the session, so that is causing a problem now, here is the more important code on the page
as you can see i registered two variables, their password and username. it worked the first time i went to the site after adding the session stuff, except when i made another account, and logged in on that, it showed the information from the account i logged in with before. and also, how would i close the session here? thanks in advance for any helpPHP Code:session_start();
if(!isset($username)) {
header("location: index.php");
exit;
}
session_register("username");
session_register("password");
srand(microtime() * 1000000);
$uniqid = uniqid(rand());
session_id($uniqid);
session_id($username);
if ($gameauth == "ok") {
$today = date("l, F jS Y");
$db_name= "hammer_time";
$table_name = "titanwarfare";
$connection = @mysql_connect("localhost", "hammer_time", "pwd") or die("Couldn't connect.");
$db = @mysql_select_db($db_name, $connection) or die("Couldn't select database.");
$sql = "SELECT username
FROM $table_name
WHERE username = \"$username\" and password = password(\"$password\")
";
$result = @mysql_query($sql, $connection) or die("Couldn't execute query.");
while ($row = mysql_fetch_array($result)) {
$username = $row['username'];
$belief = $row['belief'];
}
if (mysql_num_rows($result) == 0) {
session_unregister("username");
session_unregister("password");
header("location: index.php");
exit;
}
![]()




Bookmarks