title: Can't insert data to mysql using PDO
body: <p>Please tell me, what am I doing wrong. </p>
  
  <pre><code>&lt;?php
  if ( empty( $_POST ) ){
  ?&gt;
  &lt;form name='registration' action='pdo1.php' method='POST'/&gt;
    &lt;input type="text" name="user_name"&gt;
    &lt;input type="password" name="password"&gt;
    &lt;input type="text" name="email"&gt;
    &lt;button type="submit"&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  &lt;?php
  } else {
      // host, myU, myP and myDB are all correct
      $db_user = 'myU'; 
      $db_pass = 'myP'; 
      $db = new PDO( 'mysql:host=localhost;dbname=myDB', $db_user, $db_pass );
  
      $sql = "INSERT INTO users ( user_name, password, email ) VALUES ( :username, :password, :email )";
  
      $query = $db-&gt;prepare( $sql );
      $result = $query-&gt;execute( array( ':username'=&gt;$username, ':password'=&gt;$password, ':email'=&gt;$email ) );
  
      if($result) {
          echo "Worked!";
      }
  }
  ?&gt;
  </code></pre>
  
  <p>When I hit submit, I'm getting blank page, without "Worked!"... And obviously this doesn't insert anything to database.</p>