title: PHP - blank page after executing mysqli INSERT query with data from HTML form
body: <p>I'm new to PHP. I'm currently working on adding data into a MySQL database table 'products' from data entered into an HTML form (product name, price, category etc.) I wrote something earlier that did work, but it gave me a warning. I changed something in the code to correct the warning (I don't remember exactly what I changed), and now all I'm getting is a blank page when I click on the submit button on the form.</p>
  
  <p>I'm at a complete loss. I have been struggling over this for the past few hours. I looked at a lot of similar questions, but I still don't see/understand what's going wrong in my code. Note: <code>$con</code> is the database connection, which has already been established.</p>
  
  <pre><code>&lt;?php 
  
  // Parse the form data and put it into variables to add into the system
  if (isset($_POST['product_name'])) {
  
    $product_name = mysqli_real_escape_string($con,$_POST['product_name']);
      $price = mysqli_real_escape_string($con,$_POST['price']);
      $category = mysqli_real_escape_string($con,$_POST['category']);
      $subcategory = mysqli_real_escape_string($con,$_POST['subcategory']);
      $details = mysqli_real_escape_string($con,$_POST['details']);
  
    // See if the product name that you're trying to add is a match to another existing product
    // If it is a match, then echo out that you're trying to add a duplicate product and exit
      $sql = mysqli_query($con,"SELECT id FROM products WHERE product_name='$product_name' LIMIT 1");
      $productMatch = mysqli_num_rows($sql); // count the output amount
      if ($productMatch &gt; 0) {
          echo 'It appears that a product by that name already exists. To go back, &lt;a href="https://project.cs.cf.ac.uk/V.Bhatia/coursework/storeadmin/inventory_list.php"&gt;click here.&lt;/a&gt;';
          exit();
      }
  
    // If the product match check showed that the product doesn't exist in the database, add the product
      $sql = mysqli_query($con,"INSERT INTO products (product_name, price, details, category, subcategory) 
          VALUES('$product_name','$price','$details','$category','$subcategory'") or die (mysql_error());
  
    // This is the picture ID. Putting it in a variable "pid". Pictures are connected to products by their ID. A product of id "1" will have a picture "1.jpg"
    $pid = mysql_insert_id();
  
    // Place image in the folder
      $newname = "$pid.jpg";
      move_uploaded_file( $_FILES['fileField']['tmp_name'], "https://project.cs.cf.ac.uk/V.Bhatia/coursework/images/$newname");
  
    // Come back to the inventory_list page after the adding process is done and exit the script
    header("location: inventory_list.php"); 
      exit();
  }
  ?&gt;
  </code></pre>
  
  <p>This is the HTML form:</p>
  
  <pre><code>&lt;h3&gt;&amp;darr; Add New Inventory Item Form &amp;darr;&lt;/h3&gt;
      &lt;form action="inventory_list.php" enctype="multipart/form-data" name="myForm" id="myform" method="post"&gt;
      &lt;table width="90%" border="0" cellspacing="0" cellpadding="6"&gt;
        &lt;tr&gt;
          &lt;td width="20%" align="right"&gt;Product Name&lt;/td&gt;
          &lt;td width="80%"&gt;&lt;label&gt;
            &lt;input name="product_name" type="text" id="product_name" size="64" /&gt;
          &lt;/label&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td align="right"&gt;Product Price&lt;/td&gt;
          &lt;td&gt;&lt;label&gt;
            $
            &lt;input name="price" type="text" id="price" size="12" /&gt;
          &lt;/label&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td align="right"&gt;Category&lt;/td&gt;
          &lt;td&gt;&lt;label&gt;
            &lt;select name="category" id="category"&gt;
            &lt;option value="Clothing"&gt;Clothing&lt;/option&gt;
            &lt;/select&gt;
          &lt;/label&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td align="right"&gt;Subcategory&lt;/td&gt;
          &lt;td&gt;&lt;select name="subcategory" id="subcategory"&gt;
          &lt;option value=""&gt;&lt;/option&gt;
            &lt;option value="Hats"&gt;Hats&lt;/option&gt;
            &lt;option value="Pants"&gt;Pants&lt;/option&gt;
            &lt;option value="Shirts"&gt;Shirts&lt;/option&gt;
            &lt;/select&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td align="right"&gt;Product Details&lt;/td&gt;
          &lt;td&gt;&lt;label&gt;
            &lt;textarea name="details" id="details" cols="64" rows="5"&gt;&lt;/textarea&gt;
          &lt;/label&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td align="right"&gt;Product Image&lt;/td&gt;
          &lt;td&gt;&lt;label&gt;
            &lt;input type="file" name="fileField" id="fileField" /&gt;
          &lt;/label&gt;&lt;/td&gt;
        &lt;/tr&gt;      
        &lt;tr&gt;
          &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td&gt;&lt;label&gt;
            &lt;input type="submit" name="button" id="button" value="Add This Item Now" /&gt;
          &lt;/label&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>Otherwise, the database connection works fine. If I add entries manually with phpMyAdmin, then I'm able to query the database and echo a list on my web page. I apologise for the lengthy code, but I'm literally out of ideas and I hope someone can read this and help.</p>