Advertisement
Guest User

Untitled

a guest
May 16th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. public function Update($userid){
  2. echo $userid;
  3. $PDO = Db::getInstance();
  4. if(!empty($this->m_sUsername) && !empty($this->m_sEmail) && !empty($this->m_sPassword) && !empty($this->m_sPasswordconfirmation)){
  5. if($this->m_sPassword == $this->m_sPasswordconfirmation){
  6. $options= ['cost' => 12];
  7. $this->m_sPassword = password_hash($this->m_sPassword, PASSWORD_DEFAULT, $options);
  8.  
  9. $stmt = $PDO->prepare("UPDATE users SET username= :username, email = :email, password = :password WHERE usersid = :usersid");
  10. $stmt->bindValue(":usersid", $userid, PDO::PARAM_STR);
  11. $stmt->bindValue(":username", $this->m_sUsername, PDO::PARAM_STR);
  12. $stmt->bindValue(":email", $this->m_sEmail, PDO::PARAM_STR);
  13. $stmt->bindValue(":password", $this->m_sPassword, PDO::PARAM_STR);
  14. if($stmt->execute()){
  15. // success
  16. throw new exception("Je aanpassingen zijn doorgevoerd");
  17. }else{
  18. // error
  19. throw new exception("Je hebt ergens een fout ingevuld");
  20. }
  21. }else{
  22. // Mismatch password
  23. throw new exception("Wachtwoorden komen niet overeen");
  24. }
  25. }else{
  26. // some values are not set
  27. throw new exception("Je hebt enkele velden niet ingevuld");
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement