Advertisement
Guest User

Untitled

a guest
May 16th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. include_once ("classes/Db.class.php");
  2. include_once ("classes/config.class.php");
  3. include_once ("classes/user.class.php");
  4.  
  5. session_start();
  6. if(!isset($_SESSION['loggedIn'])){
  7. echo("not set");
  8. header("Location:index.php");
  9. }
  10. if(!empty($_POST['update'])) {
  11. echo "test 2";
  12. // todo: 1 form input velden ophalen
  13. try {
  14.  
  15. $u = new User();
  16. $u->Username = $_POST['form-username'];
  17. $u->Email = $_POST['form-email'];
  18. $u->Password = $_POST['form-password'];
  19. $u->Passwordconfirmation = $_POST['form-passwordconf'];
  20. $u->Update($_SESSION['loggedIn']);
  21. $u->profileImg($_SESSION['loggedIn']);
  22. $succes = "Je gegevens zijn aangepast";
  23. } catch (exception $e) {
  24. $succes = $e->getMessage();
  25. }
  26. }
  27.  
  28. public function Update($userid){
  29.  
  30. $PDO = Db::getInstance();
  31.  
  32. if(!empty($this->m_sUsername)){
  33.  
  34. $stmt = $PDO->prepare("UPDATE users SET username= :username WHERE usersid = :usersid");
  35. $stmt->bindValue(":usersid", $userid, PDO::PARAM_INT );//update velden velden met where m_sUserid = Userid
  36. $stmt->bindValue(":username", $this->m_sUsername, PDO::PARAM_STR);
  37. $stmt->execute();
  38. echo("username");
  39.  
  40. }
  41.  
  42. if (!empty($this->m_sEmail)){
  43.  
  44. if(!$this->checkPasswordConfirmation()){
  45. throw new exception("De update is niet correct verlopen. Check alles nog eens");
  46. }
  47.  
  48. $stmt = $PDO->prepare("UPDATE users SET email= :email WHERE usersid = :usersid");
  49. $stmt->bindValue(":usersid", $userid, PDO::PARAM_INT );//update username met " " "
  50. $stmt->bindValue(":email", $this->m_sEmail, PDO::PARAM_STR); //aleen email
  51. $stmt->execute();
  52. echo("email");
  53.  
  54. }
  55. if (!empty($this->m_sPassword)){
  56.  
  57. if(!$this->checkPasswordConfirmation()){
  58. throw new exception("de update lukt niet, beide passwoorden komen niet overeen.");
  59. }
  60.  
  61. $stmt = $PDO->prepare("UPDATE users Set password = :password WHERE usersid = :usersid");
  62. $stmt->bindValue(":usersid", $userid, PDO::PARAM_INT );//update password met " " "
  63. $stmt->bindValue(":password", $this->m_sPassword, PDO::PARAM_STR); //aleen u password
  64. $stmt->execute();
  65.  
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement