Friday, 15 August 2014

php - mysqli prepared statement not running -



php - mysqli prepared statement not running -

having issue mysqli prepared statement. function suppose create new employer in database when remove api_key parameter statement not work again. wrong?

public function createemployer($companyname, $email, $password, $confirmpass) { $response = array (); // first check if user existed in db if (! $this->isempexists ( $email )) { if ($this->comparepassword ( $password, $confirmpass )) { // generating password hash $password_hash = passhash::hash ( $password ); // generating api key $api_key = $this->generateapikey (); // insert query $stmt = $this->conn->prepare ( "insert company(name, email, password, api_key) values(?, ?, ?, ?)" ); $stmt->bind_param ( "ssss", $companyname, $email, $password_hash, $api_key); $result = $stmt->execute (); $stmt->close (); // check successful insertion if ($result) { // user inserted homecoming user_created_successfully; } else { // failed create user homecoming user_create_failed; } } else { homecoming passwords_do_not_match; } } else { // user same email existed in db homecoming user_already_existed; } homecoming $response; }

as remove api_key parameter this

public function createemployer($companyname, $email, $password, $confirmpass) { $response = array (); // first check if user existed in db if (! $this->isempexists ( $email )) { if ($this->comparepassword ( $password, $confirmpass )) { // generating password hash $password_hash = passhash::hash ( $password ); // generating api key $api_key = $this->generateapikey (); // insert query $stmt = $this->conn->prepare ( "insert company(name, email, password) values(?, ?, ?)" ); $stmt->bind_param ( "sss", $companyname, $email, $password_hash); $result = $stmt->execute (); $stmt->close (); // check successful insertion if ($result) { // user inserted homecoming user_created_successfully; } else { // failed create user homecoming user_create_failed; } } else { homecoming passwords_do_not_match; } } else { // user same email existed in db homecoming user_already_existed; } homecoming $response; }

the function returns user_create_failed

php mysqli

No comments:

Post a Comment