title: PDO bind_param is undefined method
body: <p>I'm moving away from mysql and mysqli as many users on stackoverflow are constantly saying good things about it. </p>
  
  <p>I've made a database class and have tested this, this connects fine to the database. I've tried to update my prepared statements to match however I am in unfamiliar territory and have ended up getting the following error:</p>
  
  <p><code>Fatal error: Call to undefined method PDOStatement::bind_param() in E:\xampp\htdocs\imanage\insert.php on line 50</code> </p>
  
  <p>which reflects this line:</p>
  
  <p><code>$stmt-&gt;bind_param("s", $_POST['email']);</code></p>
  
  <p>Also in regards to this I am getting the database connection success and close statements returned to me as well as the fatal error e.g:</p>
  
  <p><code>Successfully connected to the database!Successfully connected to the database!Successfully disconnected from the database!</code></p>
  
  <p>I'll explain what I am trying to achieve:</p>
  
  <ul>
  <li>Check e-mail exists in the database before registrating user</li>
  <li>if so tell user that this e-mail exists </li>
  <li>if no match insert the user into the users table and encrypt the password </li>
  </ul>
  
  <p>The relevant code is below and would appreciate if anyone could give me some guidance on this.</p>
  
  <p>index.php</p>
  
  <pre><code>        &lt;form id="loginForm" method="POST" action="class.Login.php"&gt;
          &lt;input type="text" id="email" name="email" placeholder="E-mail"&gt;
          &lt;input type="password" id="password" name="password" placeholder="Password" class="showpassword"&gt; 
          &lt;input type="submit" name="submit" value="Log in"&gt;&lt;/form&gt;
  </code></pre>
  
  <p>insert.php</p>
  
  <pre><code>public function insert() {
  
                      $stmt = $this-&gt;pdo-&gt;prepare("SELECT COUNT(*) FROM users WHERE email=?");
                      $stmt-&gt;bind_param("s", $_POST['email']);
                      $stmt-&gt;execute();
                      $stmt-&gt;bind_result($email_count);
                      $stmt-&gt;fetch();//fecth
                      $stmt-&gt;close();     
  
                      if ($email_count &gt; 0) {
                          echo "email exisits! click here to try &lt;a href='register'&gt;again&lt;/a&gt;";
                          } else {
                              //escape the POST data for added protection
                              $username = isset($_POST['username']) ? $_POST['username'] : null;
                              $cryptedPassword = crypt($_POST['password']);
                              $password = $cryptedPassword;
                              $name = isset($_POST['name']) ? $_POST['name'] : null;
                              $email = isset($_POST['email']) ? $_POST['email'] : null;
                              $stmta = $this-&gt;pdo-&gt;prepare("INSERT INTO users (username, password, name, email) VALUES (?, ?, ?, ?)");
                              //var_dump($this-&gt;pdo-&gt;error);
                              $stmta-&gt;bind_param('ssss', $username, $password, $name, $email); // bind strings to the paramater
  
                                  /* execute prepared statement */
                                  $stmta-&gt;execute();
                                  printf("%d Row inserted.\n", $stmta-&gt;affected_rows);
                                  /* close statement and connection */
                                  $stmta-&gt;close();
                  } // end email_count and insert to table
              } // end function
  </code></pre>
  
  <p>connect/class.Database.php</p>
  
  <pre><code>&lt;?php
  
  // Database connection PDO
  
  class Database {
  
      public function __construct() {
          // Connection information
          $host   = 'localhost';
          $dbname = 'imanage';
          $user   = 'root';
          $pass   = '';
  
          // Attempt DB connection
          try
          {
              $this-&gt;pdo = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
              $this-&gt;pdo-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
              echo 'Successfully connected to the database!';
          }
          catch(PDOException $e)
          {
              echo $e-&gt;getMessage();
          }
  
      }
  
       public function __destruct()
      {
          // Disconnect from DB
          $this-&gt;pdo = null;
          echo 'Successfully disconnected from the database!';
      }
  
  
  }
  
  $run = new Database();
  ?&gt;
  </code></pre>