how to automatically recognize user when logged in,retrieve his data from db?
<pre><code>&lt;?php
error_reporting(0); 
session_start(); 
if( $_SESSION["logging"]&amp;&amp; $_SESSION["logged"])
{
 print_secure_content();
}
else {
if(!$_SESSION["logging"])
{  
$_SESSION["logging"]=true;
loginform();
}
   else if($_SESSION["logging"])
   {
     $number_of_rows=checkpass();
     if($number_of_rows==1)
        {   
         $_SESSION[user]=$_GET[userlogin];
         $_SESSION[logged]=true;
         $_SESSION[user_id]=$row['id'];
         print"&lt;h1&gt;You have loged in successfully&lt;/h1&gt;";
         print_secure_content();
        }
        else{
            print "Wrong password or username, please try again.".'&lt;br/&gt;';  
            loginform();
        }
    }
 }

function loginform()
{
print "Please enter your login information to proceed with our site.".'&lt;br/&gt;'.'&lt;br/&gt;';
print ("&lt;table border='2'&gt;&lt;tr&gt;&lt;td&gt;Username&lt;/td&gt;&lt;td&gt;&lt;input type='text' name='userlogin'     size'20'&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Password&lt;/td&gt;&lt;td&gt;&lt;input type='password' name='password'       size'20'&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;").'&lt;br/&gt;';
print "&lt;input type='submit' &gt;"; 
print "&lt;h3&gt;&lt;a href='registerform.php'&gt;Register now!&lt;/a&gt;&lt;/h3&gt;";  
print "&lt;br&gt;&lt;a href='admin.php'&gt;Admin login&lt;/a&gt;&lt;br&gt;";
}

function checkpass()
{
$servername="localhost";
$username="root";
$conn=  mysql_connect($servername,$username)or die(mysql_error());
mysql_select_db("kviz",$conn);
$sql="select * from korisnici where name='$_GET[userlogin]' and       password='$_GET[password]'";
$result=mysql_query($sql,$conn) or die(mysql_error());
return  mysql_num_rows($result);
}

function print_secure_content()
{
print("&lt;b&gt;&lt;h1&gt;Hi mr.$_SESSION[user]&lt;/h1&gt;");
 print "&lt;br&gt;&lt;h2&gt;Only a logged in user can see this&lt;/h2&gt;&lt;br&gt;&lt;a href='index.htm'&gt;Počni       kviz&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;a href='logout.php'&gt;Logout&lt;/a&gt;&lt;br&gt;";    

}
?&gt;
</code></pre>

<p>This is where i insert his data to db</p>

<pre><code>    $sql = "INSERT INTO tacni (id_tacnog, id_pitanja, id_korisnik,stanje) VALUES ('', '".$row['odg_id']."','$id_korisnika','tačan')";
////$id_korisnika means id_user
</code></pre>

<p>And here is where i retrieve from db  </p>

<pre><code>    $result = mysql_query("SELECT pitanja.*,tacni.*,korisnici.*
FROM pitanja
INNER JOIN tacni ON pitanja.id = tacni.id_pitanja
INNER JOIN korisnici ON pitanja.id = korisnici.id
 WHERE korisnici.id = '$id_korisnika'");
</code></pre>

<p>I need to recognize which user is logged in,his answers have to be inserted into a table korisnici(users) which has an id field.i tried like this but nothing happens,no rows have been inserted.Can anyone help me out,and write me a few lines of code that would make this work,i will greatly appreciate any help?</p>
