title: isset not working on form submission (was actually db issue)
body: <p>This was actually an issue with my database, not with my form or my isset.
  If anyone would like to know how I fixed this in the end, Ill outline it here.</p>
  
  <p>I did as in.k suggested and used the same query as I did in the form, then added in a few lines to generate some error codes, like so :</p>
  
  <pre><code>  // query execution
      $wr_pro = "INSERT INTO products (name, description, price, cat_id) VALUES ('$name', '$description', '$price', '$categories')";
    $result = $db-&gt;query($wr_pro);
    print "$db-&gt;error()";
    if ($db-&gt;connect_error) {
        die("Connection failed: ");
    }
    if ($result === TRUE) {
    echo "Product added successfully!";
  }
    else {
    echo "Problem loading to database...";
    }
  </code></pre>
  
  <p>When I then loaded the page, I got a database error telling me that I needed to set default values for all the empty fields (it was an empty tag field that was causing the issue).</p>
  
  <p>So yeah, I didn't set up my database correctly basically.
  But I know in future now that error codes are awesome.</p>
  
  <p>-------------- ORIGINAL QUESTION -----------------
  I'm very new to this, so I'm sorry in advance if I've missed something very obvious, or my code is a bit messy.</p>
  
  <p>I'm trying to make a page that writes a new product entry into an existing mysql database table.</p>
  
  <p>From other questions asked, I've tried:</p>
  
  <ol>
  <li>adding !empty with my isset</li>
  <li>making sure that form method = "post"</li>
  <li>making sure that stuff is actually getting saved to post (before isset)</li>
  <li>tried printing the post after the isset and it didnt show up</li>
  <li>making sure that the submit button name is the same as in the isset function</li>
  <li>making sure the button name isn't submit</li>
  <li>moving the isset to before the form (I'm not actually sure why I was supposed to do this so if anyone could explain, I'd be really thankful)</li>
  </ol>
  
  <p>The errors for when it can't write to the database isn't showing, and it isn't writing to the database either, so I presume its the isset that isn't working? but I could easily be wrong.</p>
  
  <p>I'm pretty sure the connection to database is working because the form has a category section it selects from the database, and that shows on the page fine.</p>
  
  <p>I don't know if it's relevant but I'm running this on WAMP locally.</p>
  
  <p>Anyone who could point me in the right direction, I'd be very grateful.</p>
  
  <p>---- my code</p>
  
  <pre><code>    &lt;?php
  include("includes/connection.php");
  include("includes/head.html");
  include("includes/header.php");
  ?&gt;
  &lt;div class="pagecontent"&gt;
    &lt;h1&gt; Create New Product:&lt;/h1&gt;
    &lt;!-- form submission action--&gt;
    &lt;?php
    if (isset($_POST['submitwrpro'])) {
    // escape user inputs
    $name = mysqli_real_escape_string($db, $_POST['name']);
    $description = mysqli_real_escape_string($db, $_POST['description']);
    $price = mysqli_real_escape_string($db, $_POST['price']);
    $categories = mysqli_real_escape_string($db, $_POST['category_id']);
  
    // query execution
    $wr_pro = "INSERT INTO products (name, description, price, cat_id) VALUES ('$name', '$description', '$price', '$categories')";
  
    if(mysqli_query($db, $wr_pro)){
        echo "Product added successfully!";
                              }
        else{
        echo "Error writing to database $wr_pro. " . mysqli_error($db);
            }
    }
    ?&gt;
    &lt;!-- form entry --&gt;
  &lt;form action="&lt;?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?&gt;" method="post"&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;Name&lt;/td&gt;
              &lt;td&gt;&lt;input type='text' name='name'&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Price&lt;/td&gt;
              &lt;td&gt;&lt;input type='text' name='price'&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Description&lt;/td&gt;
              &lt;td&gt;&lt;textarea name='description'&gt;&lt;/textarea&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Category&lt;/td&gt;
              &lt;td&gt;
  &lt;!-- read product categories from the db --&gt;
                &lt;?php
                $req_cat = "SELECT cat_id, name FROM categories";
                $result = $db-&gt;query($req_cat);
  
                echo "&lt;select class='form-control' name='category_id'&gt;";
                echo "&lt;option&gt;Select category...&lt;/option&gt;";
                if ($result-&gt;num_rows &gt; 0) {
                    while ($row = $result-&gt;fetch_assoc()){
                        extract($row);
                        echo "&lt;option value=\"" . $row['cat_id'] . "\"&gt;" . $row["name"] . "&lt;/option&gt;";
                                                          }
                                            }
                    else {
                        echo "no results";
                          }
                echo "&lt;/select&gt;";
                ?&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;/td&gt;
              &lt;td&gt;
                  &lt;button name="submitwrpro" type="submit"&gt;Create&lt;/button&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  &lt;?php
  include("includes/footer.php");
  ?&gt;
  </code></pre>