title: Insert into table not working but no error
body: <p>Please help, I am new to php and trying to write a register page. No errors appear but the data doesn't appear in the database either. All of the validation works fine so I think there is something wrong when inserting into the table. Can anyone help?</p>
  
  <pre><code>&lt;?php 
  
  if($_SERVER['REQUEST_METHOD']=='POST')
  {
  require('connect_db.php');
  $errors = array();
  
  
  if(empty($_POST['firstname']))
      {
      $errors[]='Enter your Firstname';
      }
  else 
      {
      $fn = mysqli_real_escape_string($dbc, trim($_POST['firstname']));
      }
  
  
  if(empty($_POST['surname']))
      {
      $errors[]='Enter your Surname';
      }
  else 
      {
      $sn = mysqli_real_escape_string($dbc, trim($_POST['surname']));
      }
  
  
  if(empty($_POST['email']))
      {
      $errors[]='Enter your email address';
      }
  else 
      {
      $email = mysqli_real_escape_string($dbc, trim($_POST['email']));
      }
  
  if(!empty($_POST['pass1']))
      {
          if($_POST['pass1']!= $_POST['pass2'])
              {
                  $errors[] = 'Passwords do not match';   
              }
          else
              {
                  $p = mysqli_real_escape_string($dbc, trim($_POST['pass1']));
              }
      }
  else
      {
          $errors[]="Enter your password";
      }
  
  if (empty($errors))
      {
          $q = "INSERT INTO Users(Username, Firstname, Surname, Password)
              VALUES($email, $fn, $sn,  User, SHA1($p))";
          $r = mysqli_query ($dbc, $q);
          if ($r)
          {
              echo "success";
          }
      }
  else 
      {
          echo '&lt;h1&gt;Error&lt;/h1&gt;&lt;p id="errors"&gt;The following error/s occurred:&lt;br/&gt;';
          foreach ($errors as $error)
              {
                  echo"$error &lt;br/&gt;";
  
              }
          echo"Please try again&lt;/p&gt;";
          mysqli_close($dbc);
      }
  </code></pre>
  
  <p>}</p>