title: Insert data into multiple tables using one form
body: <p>I am trying to insert data in 2 tables using one form.</p>
  
  <p>This is my form </p>
  
  <pre><code>&lt;form action="don.php" method="post"&gt;
  &lt;tr&gt;&lt;td&gt;
      &lt;p&gt;
          &lt;label for="nume"&gt;Nume:&lt;/label&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="nume" id="nume" autocomplete="off"&gt;&lt;/td&gt;
      &lt;/p&gt;
      &lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;
      &lt;p&gt;
          &lt;label for="prenume"&gt;Prenume:&lt;/label&gt;&lt;/td&gt;
         &lt;td&gt; &lt;input type="text" name="prenume" id="prenume" autocomplete="off"&gt;&lt;/td&gt;
      &lt;/p&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;
      &lt;p&gt;
          &lt;label for="grupa"&gt;Numar telefon:&lt;/label&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="numar" id="numar" autocomplete="off"&gt;&lt;/td&gt;
      &lt;/p&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;
      &lt;p&gt;
          &lt;label for="grupa"&gt;Suma:&lt;/label&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="suma" id="suma" autocomplete="off"&gt;&lt;/td&gt;
      &lt;/p&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;
      &lt;p&gt;
          &lt;label for="grupa"&gt;Data:&lt;/label&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="data" id="data" autocomplete="off"&gt;&lt;/td&gt;
      &lt;/p&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;
      &lt;p&gt;
          &lt;label for="grupa"&gt;IBAN:&lt;/label&gt;&lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="iban" id="iban" autocomplete="off"&gt;&lt;/td&gt;
      &lt;/p&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;td&gt;&lt;input type="submit" name="submit" value="Donează" onclick="alert('Operatiune finalizata cu succes. Va multumim!')"&gt;&lt;/td&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And this is my PHP code</p>
  
  <pre><code>&lt;?php
  if(isset($_POST['submit'])){
      $con=mysql_connect("localhost","root","");
      if(!$con)
      {
          die("Nu se poate face conexiunea la baza de date" . mysql_error());
      }
  
      mysql_select_db("laborator",$con);
      $sql="INSERT INTO donator (nume, prenume, numar_telefon) VALUES ('$_POST[nume]','$_POST[prenume]','$_POST[numar]')";
      $sql="INSERT INTO donatie (suma, data_donatie, IBAN) VALUES ('$_POST[suma]','$_POST[data]','$_POST[iban]')";
      mysql_query($sql,$con);
      mysql_close($con);
  }
  ?&gt;
  </code></pre>
  
  <p>When I press the submit button it shows me the alert that my dates were inserted, but only the second <code>INSERT</code> works. Table <code>donator</code> is empty.
  What should I do to fix this problem?</p>