title: submit form data to database table
body: <p>I get problem in inserting data to database table. I have checked everything from table fields to the form fields. Everything is ok and even print_r prints the result but data is not inserted to database. it returns empty result set.
  my form code</p>
  
  <pre><code>&lt;?php include('header.php'); ?&gt;
  
  &lt;div class="page container"&gt;
      &lt;div class="row col-12 register-page"&gt;
  
  
          &lt;form class="form-horizontal" role="form" action="register-process.php" method="post"&gt;
             &lt;div class="form-group"&gt;
                &lt;label for="firstname" class="col-sm-2 control-label"&gt;First Name&lt;/label&gt;
                &lt;div class="col-sm-10"&gt;
                   &lt;input type="text" class="form-control" id="firstname" name="firstname" 
                      placeholder="Enter First Name"&gt;
                &lt;/div&gt;
             &lt;/div&gt;
             &lt;div class="form-group"&gt;
                &lt;label for="lastname" class="col-sm-2 control-label"&gt;Last Name&lt;/label&gt;
                &lt;div class="col-sm-10"&gt;
                   &lt;input type="text" class="form-control" id="lastname" name="lastname" 
                      placeholder="Enter Last Name"&gt;
                &lt;/div&gt;
             &lt;/div&gt;
             &lt;div class="form-group"&gt;
                &lt;label for="email" class="col-sm-2 control-label"&gt;Email&lt;/label&gt;
                &lt;div class="col-sm-10"&gt;
                   &lt;input type="text" class="form-control" id="email" name="email" 
                      placeholder="Enter Your Email"&gt;
                &lt;/div&gt;
             &lt;/div&gt;
             &lt;div class="form-group"&gt;
                &lt;label for="password" class="col-sm-2 control-label"&gt;Password&lt;/label&gt;
                &lt;div class="col-sm-10"&gt;
                   &lt;input type="password" class="form-control" id="password" name="password" 
                      placeholder="Enter your password"&gt;
                &lt;/div&gt;
             &lt;/div&gt;
             &lt;div class="form-group"&gt;
                &lt;label for="confirm-password" class="col-sm-2 control-label"&gt;Confirm Password&lt;/label&gt;
                &lt;div class="col-sm-10"&gt;
                   &lt;input type="password" class="form-control" id="cpassword" name="cpassword" 
                      placeholder="Confirm password"&gt;
                &lt;/div&gt;
             &lt;/div&gt;
             &lt;div class="form-group"&gt;
                &lt;label for="birth-year" class="col-sm-2 control-label"&gt;Birth Year&lt;/label&gt;
                &lt;div class="col-sm-10"&gt;
                      &lt;select id="year" class="birth-year" name="birth-year"&gt;
                          &lt;?php 
                              for($i = 1970; $i &lt; date("Y")+1; $i++){
                                  echo '&lt;option value="'.$i.'"&gt;'.$i.'&lt;/option&gt;';
                              }
  
                          ?&gt;
                      &lt;/select&gt;
                &lt;/div&gt;
             &lt;/div&gt;
              &lt;div class="form-group"&gt;
                &lt;label for="gender" class="col-sm-2 control-label register-gender"&gt;Gender&lt;/label&gt;
                &lt;div class="col-sm-10"&gt;
                      &lt;select id="registration_gender" class="select-register " required="required" name="gender"&gt;
                          &lt;option selected="selected" value=""&gt;Gender&lt;/option&gt;
                          &lt;option value="_UE_M"&gt;Male&lt;/option&gt;
                          &lt;option value="_UE_MRS"&gt;Female&lt;/option&gt;
                      &lt;/select&gt;
                &lt;/div&gt;
             &lt;/div&gt;
             &lt;div class="form-group form-action"&gt;
  
                &lt;div class="form-action"&gt;
                   &lt;input type="submit" name="submit" class="btn btn-large btn-primary" value="Lets Get Started" &gt;
                &lt;/div&gt;
             &lt;/div&gt;
          &lt;/form&gt;
  
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>
  
  and my register-process code
      </p>
  
  <pre><code>&lt;div class="page container"&gt;
      &lt;div class="row col-12 register-page"&gt;
  
      &lt;?php
  
          $fname = $_POST['firstname'];
          $lname = $_POST['lastname'];
          $email = $_POST['email'];
          $password = md5($_POST['password']);
          $cpassword = md5($_POST['cpassword']);
          $birthyear = $_POST['birth-year'];
          $gender = $_POST['gender'];
  
          if($fname &amp;&amp; $lname &amp;&amp; $email &amp;&amp; $password &amp;&amp; $cpassword){
  
              if($password == $cpassword){
  
                  include("config.php");
  
                  $insert = 'INSERT INTO users(firstname,lastname,email,password,birth-year,gender) 
                  VALUES("'.$fname.'","'.$lname.'","'.$email.'","'.$password.'","'.$birthyear.'","'.$gender.'")';
  
  
                  mysql_query($insert);
                  echo "registered successfully";
              }
              else{
  
                  header("Location: register.php");
                  echo "your password do not match.";
              }
          }
          else{
              echo "complete the form please.";
              header("Location: register.php");
          }
      ?&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>