title: logged user INSERT-ing INTO joined tables in PHP
body: <p>Here is the relational schema of my DB
  Where 'articol' is 'paper', 'citare' is 'citation' in English:</p>
  
  <p><img src="https://i.stack.imgur.com/g9Fg0.png" alt="enter image description here"></p>
  
  <p>A user is logging in with an ID and a Password and using the interface, he introduced his data in the DB. The code works very well for adding a 'paper' but now I want the user to introduce his 'citations' of the respective 'paper'. The problem is that the code allows introducing the citation in the table 'citation'('citare') but I do not know how to associate this 'citation' to 'paper' ('articol') and to the logged 'user' in the PHP code? </p>
  
  <pre><code>session_start();
  $user = $_SESSION['username'];
  $pass = mysql_real_escape_string(encrypt_decrypt('encrypt',      $_SESSION['password']));
  
  //there is code here...
  
  $AddQuery="INSERT INTO `citare`  (articolCitat, titluCitare, autoriCitare, publicatieCitare, isiCitare, volCitare, noCitare, anCitare, linkCitare) VALUES ('$_POST[narticolcitat]','$_POST[ntitlucitare]','$_POST[nautoricitare]','$_POST[npublicatiecitare]','$_POST[nisicitare]','$_POST[nvolcitare]','$_POST[nnocitare]','$_POST[nancitare]','$_POST[nlinkcitare]' )";
  mysql_query($AddQuery, $link);
  $last_id_inserted_from_citare = mysql_insert_id($link);
  $AddQuery="INSERT INTO artcitare (idArticol, idCitare) VALUES ('{$_POST['hidden_articol']}','".$last_id_inserted_from_citare."')";
  mysql_query($AddQuery, $link);
  </code></pre>