title: PHP PDO-Error while inserting data into database
body: <p>I´m trying to insert data into database but for some reason the code doesn´t work. Here is form i´m using.</p>
  
  <pre><code>&lt;form id="registration" method="post" action="index.php" style="display: none;"&gt;
                  &lt;label for="username" class="username"&gt;
                      Username
                  &lt;/label&gt;    
                  &lt;input type="text" name="r-username" id="r-username" placeholder="Username" required/&gt;
                  &lt;label for="password"&gt;
                      Password
                  &lt;/label&gt;    
                  &lt;input type="password" name="password" id="password" placeholder="Password" required/&gt;
                  &lt;label for="check_password" class="check_password"&gt;
                      Password Check
                  &lt;/label&gt;    
                  &lt;input type="password" name="check-password" id="check_password" placeholder="Password again" required/&gt;
                  &lt;label for="e-mail"&gt;
                      E-mail
                  &lt;/label&gt;    
                  &lt;input type="email" name="e-mail" id="e-mail" placeholder="E-mail" required/&gt;
                  &lt;label for="check-e-mail" class="check_email"&gt;
                      E-mail Check
                  &lt;/label&gt;    
                  &lt;input type="email" name="check-e-mail" id="check-e-mail" placeholder="E-mail again" required/&gt;
                  &lt;input type="submit" name="submit" class="submit" value="Register"/&gt; 
              &lt;/form&gt;
  </code></pre>
  
  <p>And here is PHP code:</p>
  
  <pre><code>if(isset($_POST['r-username']))
                  {
                      $name=$_POST['r-username'];
                      $pass=$_POST['password'];
                      $passcheck=$_POST['check-password'];
                      $mail=$_POST['e-mail'];
                      $mailcheck=$_POST['check-e-mail'];
                      if($name==''||$pass==''||$passcheck==''||$mail==''||$mailcheck=='')
                      {
                          echo "&lt;script type='text/javascript'&gt;alert('Field must be filled.');&lt;/script&gt;";
                      }
                      elseif(strlen($pass)&lt;=6) 
                      {
                          echo "&lt;script type='text/javascript'&gt;alert('Password is too short.');&lt;/script&gt;";
                      }
                      elseif(strlen($pass)&gt;=20) 
                      {
                          echo "&lt;script type='text/javascript'&gt;alert('Password is too long.');&lt;/script&gt;";
                      }
                      elseif($pass!==$passcheck) 
                      {
                          echo "&lt;script type='text/javascript'&gt;alert('Passwords must be same.');&lt;/script&gt;";
                      }
                      elseif($mail!==$mailcheck) 
                      {
                          echo "&lt;script type='text/javascript'&gt;alert('Emails must be same.');&lt;/script&gt;";
                      }
                      else
                      {
                          $sql5='INSERT INTO user(user_name,password,joined,user_email) VALUES(:username,:password,Now(),:email)';
                          $query1=$db-&gt;prepare($sql5);
                          $result=$query1-&gt;execute(array( ":username" =&gt; $name, 
                                                          ":password" =&gt; $pass, 
                                                          ":email" =&gt; $mail
                                                        ));
                          if($result)
                          {
                              echo "&lt;script type='text/javascript'&gt;alert('Inserted.');&lt;/script&gt;";
                          }
                          else
                          {
                              echo "&lt;script type='text/javascript'&gt;alert('ERROR.');&lt;/script&gt;";
                          }
                      }
                  }
  </code></pre>
  
  <p>Code runs but id doesn´t do anything. It just reloads page echoes message ERROR and inserts no data into database. Sorry for my bad english and thanks for possible answers :).</p>