title: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'first_name' cannot be null
body: <p>i have a registration form that should insert data but im always getting this error after submitting my form</p>
  
  <blockquote>
    <p>SQLSTATE[23000]: Integrity constraint violation: 1048 Column
    'first_name' cannot be null</p>
  </blockquote>
  
  <p>HTML under sign-up.php</p>
  
  <pre><code>&lt;div class="form-group"&gt;
                  &lt;label&gt;Complete Name:&lt;/label&gt;
                  &lt;input type="text" class="form-control" name="fname" placeholder="First Name"&gt;&lt;br&gt;
                  &lt;input type="text" class="form-control" name="mname" placeholder="Middle Name"&gt;&lt;br&gt;
                  &lt;input type="text" class="form-control" name="lname" placeholder="Last Name (this will be your username)" 
                  value="&lt;?php if(isset($error)){echo $uname;}?&gt;"&gt;&lt;br&gt;
              &lt;/div&gt;
              &lt;div class="form-group"&gt;
                  &lt;input type="password" class="form-control" name="txt_upass" placeholder="Password (more than 6 characters)"&gt;&lt;br&gt;
              &lt;/div&gt;
  </code></pre>
  
  <p>PHP under sign-up.php</p>
  
  <pre><code>if(isset($_POST['btn-signup']))
  {   
      $fName = strip_tags($_POST['fname']);
      $mName = strip_tags($_POST['mname']);
      $uname = strip_tags($_POST['lname']);
      $upass = strip_tags($_POST['txt_upass']);
  
      if($uname=="")  {
          $error[] = "provide username !";    
      }
      else if($upass=="") {
          $error[] = "provide password !";
      }
      else if(strlen($upass) &lt; 6){
          $error[] = "Password must be atleast 6 characters"; 
      }
      else
      {
          try
          {
              $stmt = $user-&gt;runQuery("SELECT last_name FROM users WHERE last_name=:uname");
              $stmt-&gt;execute(array(':uname'=&gt;$uname));
              $row=$stmt-&gt;fetch(PDO::FETCH_ASSOC);
  
              if($row['last_name']==$uname) {
                  $error[] = "Username already taken !";
              }
              else
              {
                  if($user-&gt;register($fName,$mName,$uname,$upass)){   
                      $user-&gt;redirect('sign-up.php?joined');
                  }
              }
          }
          catch(PDOException $e)
          {
              echo $e-&gt;getMessage();
          }
      }   
  }
  </code></pre>
  
  <p>PHP function under class.user.php</p>
  
  <pre><code>public function register($fName,$mName,$uname,$upass)
      {
          try
          {
              $new_password = password_hash($upass, PASSWORD_DEFAULT);
  
              $stmt = $this-&gt;conn-&gt;prepare("INSERT INTO users(first_name,middle_name,last_name,user_pass) 
                                                         VALUES(:fName,:mName,:uname,:upass)");
  
              $stmt-&gt;bindparam(":fName", $first_name);
              $stmt-&gt;bindparam(":mName", $middle_name);                                    
              $stmt-&gt;bindparam(":uname", $last_name);
              $stmt-&gt;bindparam(":upass", $new_password);                                            
  
              $stmt-&gt;execute();   
  
              return $stmt;   
          }
          catch(PDOException $e)
          {
              echo $e-&gt;getMessage();
          }               
      }
  </code></pre>