title: Adding a new row to a sql table using a form submit button
body: <p>I am trying to add a new user to a table. I've created the form, connected to the database and created the query. When I press the submit button it takes me to the next page but a new row isn't made and the data is lost. Note: Connection details are right, just changed to show you :). Also the tables User_ID column is set to auto increment.
  Please help.
  (I have looked at other similar questions but I still can't get it working)</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;div&gt;
  &lt;form action ="/Product.php" method="post"&gt;
  &lt;label&gt;&lt;h1&gt;Add User&lt;/h1&gt;&lt;/label&gt;&lt;br&gt;
   &lt;label&gt;Username&lt;/label&gt;
   &lt;input type="text" name="Username"&gt;&lt;br&gt;
   &lt;label&gt;Password&lt;/label&gt;
   &lt;input type="text" name="Password"&gt;&lt;br&gt;
   &lt;label&gt;User type&lt;/label&gt;
  &lt;select multiple&gt;
    &lt;option value="Admin"&gt;Admin&lt;/option&gt;
    &lt;option value="Registered user"&gt;Registered user&lt;/option&gt;
    &lt;option value="Guest"&gt;Guest&lt;/option&gt;
  &lt;/select&gt;
   &lt;input name="Submit" type="Submit"/&gt;&lt;br&gt;
  &lt;/form&gt;
  &lt;/div&gt; 
  
  
  &lt;?php
  
  $connection = mysqli_connect('host', 'username', 'password', 'database');
  
  if (mysqli_connect_error()){ 
   echo "Failed to connect to MySQL: " . mysqli_connect_error();
  } else {
  
  if(isset($_POST['Submit'])){
  
          $Username=$_POST['Username'];
          $Password=$_POST['Password'];
          $User_Type=$_POST['User_Type'];
  
      $query = "INSERT INTO Login (User_ID, Username, Password, User_Type)         VALUES('','$Username','$Password','$User_Type')";
  
      $result = mysqli_query($query);      
      }
  }
  ?&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>