I made this little function that finds user's ID and I have that ID available across website because I included it before <head>
$result=mysql_query("SELECT ID FROM korisnici WHERE username='".$_COOKIE["user"]."' AND password='".$_COOKIE["pass"]."'");
$get=mysql_fetch_assoc($result);
$ID_KORISNIK=$get["ID"];
if(empty($ID_KORISNIK))
{
echo '
<script>window.location="IDerror.php";</script>
';
}
So whan I want to SELECT or INSERT into database I could use
$r=mysql_query("SELECT * FROM uzg WHERE IDkorisnik='$ID_KORISNIK'");
or use JOIN
$r=mysql_query("SELECT * FROM uzg JOIN (uzg.IDkorisnik=korisnici.ID) WHERE korisnici.username='$_COOKIE["user"]' AND korisnici.password='$_COOKIE["pass"]'");
What do you think, which one is better or effective?