how to get the user id and store it into the database
<p>i'm new to php and trying to upload a file and store the current logged in user id in the database with the file uploaded , that's my upload file form : </p>

<pre><code>&lt;?php 
error_reporting(E_ALL ^ E_NOTICE);
session_start();
?&gt;
&lt;form method="post" enctype="multipart/form-data"&gt;
&lt;table width="350" border="0" cellpadding="1"
cellspacing="1" class="box"&gt;
&lt;tr&gt;
&lt;td&gt;please select a file&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;input type="hidden" name="MAX_FILE_SIZE"
value="16000000"&gt;
&lt;input name="pdf" type="file" id="pdf" accept="application/pdf"&gt; 
&lt;/td&gt;
&lt;td width="80"&gt;&lt;input name="upload"
type="submit" class="box" id="upload" value=" Upload "&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;?php
if(isset($_POST['upload'])&amp;&amp;$_FILES['pdf']['size']&gt;0)
{
$fileName = $_FILES['userfile']['name'];
$tmpName  = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$filePath = $_FILES['userfile']['path'];
$fileType = $_FILES['userfile']['type'];
$fileType=(get_magic_quotes_gpc()==0 ? mysql_real_escape_string(
$_FILES['userfile']['type']) : mysql_real_escape_string(
stripslashes ($_FILES['userfile'])));
$fp      = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
if(!get_magic_quotes_gpc())
{
    $fileName = addslashes($fileName);
}
$con = mysql_connect('localhost', 'root', '') or die(mysql_error());
$db = mysql_select_db('workflow', $con);
if($db){
$query = "INSERT INTO upload (name, size, type, path  ) ".
"VALUES ('$fileName', '$fileSize', '$fileType', '$filePath')";
mysql_query($query) or die('Error, query failed'); 
mysql_close();
echo "&lt;br&gt;File $fileName uploaded&lt;br&gt;";
}else { echo "file upload failed"; }
} 
?&gt; 
</code></pre>

<p>and that is my login form : </p>

<pre><code>&lt;?php 
error_reporting(E_ALL ^ E_NOTICE);
session_start(); 
?&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;title&gt;LOGIN FORM&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;?php 
$form= "&lt;form action='login.php' method='post'&gt;
  &lt;table&gt;
    &lt;tr&gt;
      &lt;td&gt;username :&lt;/td&gt;
      &lt;td&gt;&lt;input type='text' name='user'/&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'/&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;/td&gt;
      &lt;td&gt;&lt;input type='submit' name='loginbtn' value='login' /&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
&lt;/form&gt;";
if ($_POST['loginbtn']) {
  $user = $_POST['user'];
  $password = $_POST['password'];
  if ($user) {
    if ($password) {
      require ("connect1.php");
      $password= md5(md5("jdhbjdbj".$password."jdh645fdj"));
      $query = mysql_query("SELECT * FROM users WHERE username='$user'");
      $numrows = mysql_num_rows($query);
      if ($numrows == 1) {
        $row = mysql_fetch_assoc($query);
        $dbid=$row['id'];
        $dbuser=$row['username'];
        $dbpass=$row['password'];
        $dbactive=$row['active'];
        if ($password == $dbpass) {
          if ($dbactive == 1) {
            $_SESSION['userid'] = $dbid;
            $_SESSION['username'] = $dbuser;

            echo "you have been logged in as &lt;b&gt;$dbuser&lt;/b&gt;. &lt;a href='insert1.php' &gt;Click here&lt;/a&gt; to go to the insertion page ";

          }
          else echo "you must activate your account to login .$form";
        }
        else echo "You didn't enter a password . $form";
      }
      else echo "the user name u entered wasn't found . $form";;
      mysql_close();
    }
    else echo "You must enter your password .$form";
  }
  else echo "You must enter your username .$form";
}
else echo $form;

?&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>i want to get the current user id and store it with the file i upload her can any one help ???</p>