0

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.

2
Contributors
3
Replies
18
Views
4 Years
Discussion Span
Last Post by JorgeM
0

How and where would I add it? I thought that might be the problem however, I wasn't sure...

1

Probably this after line 10

        $stmt->bindValue( "email", $this->email, PDO::PARAM_STR );
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.