Code fails to obtain "id" from table

The table, users, contains the columns “id” (an auto increment value), username, and password.
username is successfully identified and the user can log in fine, but their “id” is not stored as a session variable like username is, why is this?

It is not doing so becuase this line
$_SESSION[‘uid’]= mysql_query($getuid) or die(mysql_error());

the function mysql_query returns a resource on success, or FALSE on error not the value

This should do the trick
if($login = mysql_fetch_assoc($checkUserQueryResults)){
$_SESSION[id] = $login[id];
$_SESSION[‘username’] = $login[‘username’];
$confirm = “Thank you, you are now logged in as $userLogin. <br />You may now continue to the <a href=\“index.php\”>index</a>”;
//rather user header function

Just as it was.I think this login process can be made better.
But it will work any way.


Thank you!!

Off Topic:

foreach($_GET as $key => $value){
$$key = $value;

Please oh please don’t do this. There’s a reason register_globals was removed from PHP as 5.4.0, because it’s super insecure. Don’t emulate or fake it instead, just don’t use it; use $_GET (or your own wrapper around $_GET) instead.