I am having trouble with a registration script that I am trying to implement. When I click the "Register" button, I get this error:
SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens
This is my coding for the register function:
`public function register() {
$correct = false;
try {
$con = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD );
$con->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$sql = "INSERT INTO users(UserID, Username, Password, Email, Activated) VALUES('', :username, :password, :email, '1')";
$stmt = $con->prepare( $sql );
$stmt->bindValue( "username", $this->username, PDO::PARAM_STR );
$stmt->bindValue( "password", hash("sha256", $this->password . $this->salt), PDO::PARAM_STR );
$stmt->execute();
//Show Pop Up Box Saying That The Account Has Been Created Successfully
return ("<SCRIPT LANGUAGE='JavaScript'>
window.alert('Your account has been created successfully. You may now login.')
window.location.href='index.php';
</SCRIPT>");
}catch( PDOException $e ) {
return $e->getMessage();
}
}`
Please help!
Thanks so much.