title: Using one form to upload into multiple database tables
body: <p>I need to use one form to upload a "holiday home". But the details needed for the property are stored in multiple tables - Properties, Prices, County and Image. This is my form code:    </p>
  
  <pre><code>&lt;form class="pure-form pure-form-stacked" action="propsubmit.php" 
  method="post" name="uploadproperty"  enctype="multipart/form-data" 
  style="margin-left: 20px; color:black"&gt;
      &lt;fieldset&gt;&lt;br&gt;
  
          &lt;label for="propertyname" class="button button-alt" 
  style="background-color:white" &gt;Property Name:&lt;/label&gt;
          &lt;input id="propertyname" name="propertyname" type="text" placeholder="Enter name here.... " size="50" required="required"/&gt;&lt;br&gt;
  
          &lt;label for="description" class="button button-alt" style="background-color:white "&gt; Description:&lt;/label&gt;
          &lt;textarea rows="10" cols="100" name="description" placeholder="Enter description here...." required="required"&gt;&lt;/textarea&gt;&lt;br&gt;    
  
          &lt;label for="county" class="button button-alt" style="background-color:white"&gt;County:&lt;/label&gt;
          &lt;select id="county" name="county" placeholder="Choose County" required="required"&gt;
          &lt;option value="antrim"&gt;Antrim&lt;/option&gt;
          &lt;option value="down"&gt;Down&lt;/option&gt;
          &lt;option value="derry"&gt;Derry&lt;/option&gt;
          &lt;/select&gt;
  
          &lt;label for="amin" class="button button-alt" style="background-color:white" &gt;Autumn minimum price:&lt;/label&gt;
          &lt;input id="amin" name="amin" type="text" placeholder="Price.... " size="10" required="required"/&gt;&lt;br&gt;
  
          &lt;label for="amax" class="button button-alt" style="background-color:white" &gt;Autunm maximum price:&lt;/label&gt;
          &lt;input id="amax" name="amax" type="text" placeholder="Price.... " size="10" required="required"/&gt;&lt;br&gt;
  
          &lt;label for="spmin" class="button button-alt" style="background-color:white" &gt;Spring minimum price:&lt;/label&gt;
          &lt;input id="spmin" name="spmin" type="text" placeholder="Price.... " size="10" required="required"/&gt;&lt;br&gt;
  
          &lt;label for="spmax" class="button button-alt" style="background-color:white" &gt;Spring maximum price:&lt;/label&gt;
          &lt;input id="spmax" name="spmax" type="text" placeholder="Price.... " size="10" required="required"/&gt;&lt;br&gt;
  
          &lt;label for="sumin" class="button button-alt" style="background-color:white" &gt;Summer minimum price:&lt;/label&gt;
          &lt;input id="sumin" name="sumin" type="text" placeholder="Price.... " size="10" required="required"/&gt;&lt;br&gt;
  
          &lt;label for="sumax" class="button button-alt" style="background-color:white" &gt;Summer maximum price:&lt;/label&gt;
          &lt;input id="sumax" name="sumax" type="text" placeholder="Price.... " size="10" required="required"/&gt;&lt;br&gt;  
  
          &lt;label for="wmin" class="button button-alt" style="background-color:white" &gt;Winter minimum price:&lt;/label&gt;
          &lt;input id="wmin" name="wmin" type="text" placeholder="Price.... " size="10" required="required"/&gt;&lt;br&gt;  
  
          &lt;label for="wmax" class="button button-alt" style="background-color:white" &gt;Winter maximum price:&lt;/label&gt;
          &lt;input id="wmax" name="wmax" type="text" placeholder="Price.... " size="10" required="required"/&gt;&lt;br&gt;       
  
          &lt;label for="propimage"  class="button button-alt" style="background-color:white"&gt;Images:&lt;/label&gt; 
          &lt;input name="propimgs" type="file" multiple="required"/&gt;&lt;br&gt;  
  
  
  
  
  
          &lt;br&gt;
  
          &lt;button type="submit" class="button button-alt" name="search"&gt;Upload Property&lt;/button&gt;
          &lt;button type="reset" class="button button-alt"&gt;Reset&lt;/button&gt;
  
  
            &lt;/fieldset&gt;
    &lt;/form&gt;
  </code></pre>
  
  <p>This is my submitprop code:</p>
  
  <pre><code>&lt;?php
  include("../connections/conn.php");
  
  
  
  $sentpropname = $_POST['propertyname'];
  $sentpropdesc = $_POST['description'];
  
  $insertquery1 = "INSERT INTO Properties (ID, Name, Description, County_ID)
                      VALUES (NULL, '$sentpropname', '$sentpropdesc', NULL)";
  $result1 = mysqli_query($conn, $insertquery1);
  
  $sentpropcounty = $_POST['county'];
  
  $insertquery2 = "INSERT INTO County (ID, County)
                      VALUES (NULL, '$sentpropcounty')";
  $result2 = mysqli_query($conn, $insertquery2);
  
  $filename = $_FILES['propimgs']['name']; 
  $filetemp = $_FILES['propimgs']['tmp_name'];
  
  
  move_uploaded_file($filetemp,"../images/$filename");
  
  
  $insertquery3 = "INSERT INTO Image (ID, Property_ID, Path) VALUES (NULL, 0, 
  '$filename')";
  $result3 = mysqli_query($conn, $insertquery3);
  
  
  
  $sentpriceautummin = $_POST['amin'];
  $sentpriceautummax = $_POST['amax'];
  $sentpricespringmin = $_POST['spmin'];
  $sentpricespringmax = $_POST['spmax'];
  $sentpricesummermin = $_POST['sumin'];
  $sentpricesummermax = $_POST['sumax'];
  $sentpricewintermin = $_POST['wmin'];
  $sentpricewintermax = $_POST['wmax'];
  
  $insertpricequery = "INSERT INTO Prices"
    . "(id, Property_ID, AutumnMinPrice, AutumnMaxPrice, SpringMinPrice, "
    . "SpringMaxPrice, SummerMinPrice, SummerMaxPrice, WinterMinPrice, 
    WinterMaxPrice)"
    . "VALUES(0, 0, '$sentpriceautummin', '$sentpriceautummax', "
    . "'$sentpricespringmin', '$sentpricespringmax', '$sentpricesummermin', "
    . "'$sentpricesummermax', '$sentpricewintermin', '$sentpricewintermax')";
  
        $resultpricequery = mysqli_query($conn, $insertpricequery) or die(mysqli_error($conn));
        mysqli_close($conn);
  </code></pre>
  
  <p>When I click upload, the property is not uploading into the database. Is there any specific thing I've missed out in my code?</p>