title: Why does my input form not send data to my SQL database?
body: <p>I am trying to send input data to an SQL database, but it doesn't work. Database name is scifair and table name (within database) is users. The issue resides in these two php files. I am using phpmyadmin to manage the SQL database. Please tell me what I need to fix as soon as possible!</p>
  
  <p>add.php</p>
  
  <pre><code>&lt;?php
  
  include_once 'includes/db_connect.php';
  
  $firstname = $email = '';
      $errors = array('firstname'=&gt;'', 'email'=&gt;'');
  
      if(isset($_POST['submit'])){
      // check name
      if(empty($_POST['firstname'])){
          $errors['firstname'] = 'Enter a name! &lt;br /&gt;';
      } else {
          echo htmlspecialchars($_POST['firstname']);
          $firstname = $_POST['firstname'];
          if(!preg_match('/^[a-zA-Z]+$/', $firstname)){
              $errors['firstname'] = 'Name can only be letters! &lt;br /&gt;';
          }
      }
      // check email
      if(empty($_POST['email'])){
          $errors['email'] = 'Enter an email! &lt;br /&gt;';
      } else {        
          echo htmlspecialchars($_POST['email']);
          $email = $_POST['email'];
          if(!filter_var($email, FILTER_VALIDATE_EMAIL)){
              $errors['email'] = 'Invalid email! &lt;br /&gt;';
          }
      }
  
      if(array_filter($errors)){
          echo ' errors in the form';
      } else {
          echo ' form is valid';
      }
  }
  
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;SCIENCE FAIR&lt;/title&gt;
  &lt;link rel="stylesheet" href="style.css"&gt;
      &lt;section class ="container grey-text"&gt;
      &lt;form class="white" action="add.php" method="POST"&gt;
      &lt;tr&gt;
          &lt;label&gt;First Name:&lt;/label&gt;
          &lt;td&gt;&lt;input type="text" name="firstname" placeholder="First Name"&gt;&lt;/td&gt;&lt;/br&gt;
          &lt;?php echo $errors['firstname']; ?&gt;&lt;/div&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;label&gt;Email:&lt;/label&gt;
          &lt;td&gt;&lt;input type="text" name="email" placeholder="Email"&gt;&lt;/td&gt;&lt;/br&gt;
          &lt;?php echo $errors['email']; ?&gt;&lt;/div&gt;
      &lt;/tr&gt;
          &lt;div class="center"&gt;
              &lt;td colspan="2"&gt;&lt;input type="submit" name="submit" value="Submit"&gt;&lt;/td&gt;
          &lt;/div&gt;
      &lt;/form&gt;
  
  &lt;/section&gt;
  &lt;/html&gt;
  &lt;?php
  if(isset($_POST['submit'])) {
      $firstname = $_POST['firstname'];
      $email = $_POST['email'];
  
      $query = "INSERT INTO users (name, email) VALUES ($firstname, $email)";
      mysqli_query($conn, $query);
  }
  ?&gt;
  </code></pre>
  
  <p>db_connect.php</p>
  
  <pre><code>&lt;?php
  
  $dbServername = "localhost";
  $dbUsername = "scifair";
  $dbPassword = "password";
  $dbName = "scifair";
  // connect to database
  $conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);
  
  // check connection
  if(!$conn){
      echo 'Connection error: ' . mysqli_connect_error();
  }
  ?&gt;
  </code></pre>