title: My values are not successfully inserting into my table. When I test the connection it is successful. What's wrong with my code?
body: <p>Here is my index.php:</p>
  <pre><code>    private static function connection() {
  
          $servername = &quot;localhost&quot;;
          $username = &quot;root&quot;;
          $password = &quot;&quot;;
          $dbname=&quot;social&quot;;
  
          $conn = new PDO(&quot;mysql:host=$servername;dbname=$dbname&quot;, $username, $password);
          $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
          return $conn;
      }
      public static function query($query, $params =array()) {
          $statement=self::connect-&gt;prepare($query);
          $statement-&gt;execute($params);
      }
  </code></pre>
  <p>And here is my login.php:</p>
  <pre><code>include('index.php');
  if (isset($_POST['createaccount'])){
  $username = $_POST['username'];
  $password = $_POST['password'];
  $email = $_POST['email'];
  DB::query('INSERT INTO users (username, password, email) VALUES (:username, :password, :email)', array(':username'=&gt;$username, ':password'=&gt;$password, ':email'=&gt;$email));
  echo &quot;Success!&quot;;
  }  
  </code></pre>
  <p>And here is my html form which is in the login.php under the php tags:</p>
  <pre><code>&lt;h1&gt;Register&lt;/h1&gt;
      &lt;form class=&quot;login.php&quot; method=&quot;post&quot; action=&quot;login.php&quot;&gt;
          &lt;input type=&quot;text&quot; name=&quot;username&quot; value=&quot;&quot; placeholder=&quot;Username ...&quot; required&gt;&lt;br/&gt;
          &lt;input type=&quot;password&quot; name=&quot;password&quot; value=&quot;&quot; placeholder=&quot;Password ...&quot; required&gt;&lt;br/&gt;
          &lt;input type=&quot;email&quot; name=&quot;email&quot; value=&quot;&quot; placeholder=&quot;someone@gmail.com&quot; required&gt;&lt;br/&gt;
          &lt;input type=&quot;submit&quot; name=&quot;createaccount&quot; value=&quot;submit&quot;&gt; &lt;br/&gt;
      &lt;/form&gt;
  </code></pre>
  <p>I am following a tutorial made five years ago. I am using Sequel Pro and my table is called users. I have four fields: id, username, password, and email.</p>
  <p>Thanks for help</p>