For some reason, my sessions aren't working correctly - everytime multiple users are using my forum, they end up posting as each other - the session's than get mixed up, and they're logged in as each other!
Heres my code for logging in
<?php
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
session_start();
include("config.php");
?>
<body bgcolor="#696969" text="#ffffff" link="#ffffff" background="menubg.jpg">
<?
$a = new database();
$a->connect();
$quser = mysql_query("SELECT * FROM login WHERE user='".$_POST['user']."' AND pword='".$_POST['pword']."'");
$usern = $row['user'];
if ($row = mysql_fetch_array($quser, MYSQL_ASSOC)) {
print "User ".$row['user']." has successfully logged in<br>";
//print "Your session is: ".session_id().".<br>";
$_SESSION[user] = $row['user'];
session_register("user");
$user = $row['user'];
print "Go <a href=\"index.php\">back</a> to the front page.";
print "<meta http-equiv=\"refresh\" content=\"1;URL=menu.php\">";
//$add_user = "INSERT INTO login (laston) VALUES ('".date(m/d/Y H:i)."' )";
//$updatetime = "UPDATE login SET laston= '" . date(\"m/d/Y H:i\") . "' WHERE user = '".$_POST['user']."'";
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$updatetime = "UPDATE login SET laston= '".date("m/d/Y H:i")."', lastip= '$hostname' WHERE user = '".$_POST['user']."'";
mysql_query($updatetime) or die(mysql_error());
}
else {
print "Invalid username or password<br>";
print "<meta http-equiv=\"refresh\" content=\"1;URL=menu.php\">";
}
?>
Then whenever I call it, I use
$_SESSION['user']
See any problems with this? Its really buggy... And obviously will have problems, once I get multiple people constantly on.