title: Error Creating record in MySQL: "Integrity constraint violation"
body: <p>I am trying to create a registration file and I used this code for creating it:</p>
  
  <pre><code>&lt;?php
  require 'connection.php';
  
  if (isset($_POST['submit'])) {
      $res= $conn-&gt;prepare("Insert into user (Name,Email,user_name,password)Values (:name,:email,:user,md5(:pass))");
      $res-&gt;bindParam(':name', $name);
      $res-&gt;bindParam(':email', $email);
      $res-&gt;bindParam(':user', $user);
      $res-&gt;bindParam(':pass', $pass);
  
      $name = $_POST['name'];
      $email = $_POST['email'];
      $username =$_POST['user'];
      $password = $_POST['pass'];
  
      $res-&gt;execute();
  
      if ($res==TRUE) {
          echo 'Registered successfully';
      } else {
          echo 'There was some error.';
      }      
  }    
  ?&gt;
  </code></pre>
  
  <p>But I get this error:</p>
  
  <blockquote>
    <p>Integrity constraint violation: 1048 Column 'user_name' cannot be
    null'</p>
  </blockquote>
  
  <p>Here is the <strong>HTML</strong> part of my code.</p>
  
  <pre><code> &lt;body&gt;
          &lt;form action="Registration.php" method="post" &gt;
              Name:&lt;br&gt;
              &lt;input type="text" name="name"/&gt;&lt;br&gt;
              Email:&lt;br&gt;
              &lt;input type="text" name="email"  /&gt;&lt;br&gt;
              Username:&lt;br&gt;
              &lt;input type="text" name="user" /&gt;&lt;br&gt;
              Password:&lt;br&gt;
              &lt;input type="password" name="pass" /&gt;&lt;br&gt;                
              &lt;input type="submit" name="submit" value="SignUp!"/&gt;
          &lt;/form&gt;       
      &lt;/body&gt;
  </code></pre>