Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function Update($userid){
- echo $userid;
- $PDO = Db::getInstance();
- if(!empty($this->m_sUsername) && !empty($this->m_sEmail) && !empty($this->m_sPassword) && !empty($this->m_sPasswordconfirmation)){
- if($this->m_sPassword == $this->m_sPasswordconfirmation){
- $options= ['cost' => 12];
- $this->m_sPassword = password_hash($this->m_sPassword, PASSWORD_DEFAULT, $options);
- $stmt = $PDO->prepare("UPDATE users SET username= :username, email = :email, password = :password WHERE usersid = :usersid");
- $stmt->bindValue(":usersid", $userid, PDO::PARAM_STR);
- $stmt->bindValue(":username", $this->m_sUsername, PDO::PARAM_STR);
- $stmt->bindValue(":email", $this->m_sEmail, PDO::PARAM_STR);
- $stmt->bindValue(":password", $this->m_sPassword, PDO::PARAM_STR);
- if($stmt->execute()){
- // success
- throw new exception("Je aanpassingen zijn doorgevoerd");
- }else{
- // error
- throw new exception("Je hebt ergens een fout ingevuld");
- }
- }else{
- // Mismatch password
- throw new exception("Wachtwoorden komen niet overeen");
- }
- }else{
- // some values are not set
- throw new exception("Je hebt enkele velden niet ingevuld");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement