I was just trying out this code:
public function create_account($username, $password, $email) {
$password = sha1($password);
$activation_key = md5($username . $email);
$this->STH = $this->DBH->prepare("INSERT INTO users(username, password, email, activation_key, created) VALUES(:username, :password, :email, :activation_key, :created)");
$this->STH->bindParam(':username', $username);
$this->STH->bindParam(':password', $password);
$this->STH->bindParam(':email', $email);
$this->STH->bindParam(':activation_key', $activation_key);
$this->STH->bindParam(':created', time());
$this->STH->execute();
if ($this->DBH->lastInsertId()) {
//$this->send_mail($username, $email);
return true;
} else {
//Log
}
}
Now it is working, indeed. But just a minute ago, I had missed a ) on the SQL statement, which led that the data was not inserted. I tried with the try { } catch block - But I didn't receive any error, still - Is it suppose to be so? How can I fix this code, to properly log the PDO error (if received)