Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include_once ("classes/Db.class.php");
- include_once ("classes/config.class.php");
- include_once ("classes/user.class.php");
- session_start();
- if(!isset($_SESSION['loggedIn'])){
- echo("not set");
- header("Location:index.php");
- }
- if(!empty($_POST['update'])) {
- echo "test 2";
- // todo: 1 form input velden ophalen
- try {
- $u = new User();
- $u->Username = $_POST['form-username'];
- $u->Email = $_POST['form-email'];
- $u->Password = $_POST['form-password'];
- $u->Passwordconfirmation = $_POST['form-passwordconf'];
- $u->Update($_SESSION['loggedIn']);
- $u->profileImg($_SESSION['loggedIn']);
- $succes = "Je gegevens zijn aangepast";
- } catch (exception $e) {
- $succes = $e->getMessage();
- }
- }
- public function Update($userid){
- $PDO = Db::getInstance();
- if(!empty($this->m_sUsername)){
- $stmt = $PDO->prepare("UPDATE users SET username= :username WHERE usersid = :usersid");
- $stmt->bindValue(":usersid", $userid, PDO::PARAM_INT );//update velden velden met where m_sUserid = Userid
- $stmt->bindValue(":username", $this->m_sUsername, PDO::PARAM_STR);
- $stmt->execute();
- echo("username");
- }
- if (!empty($this->m_sEmail)){
- if(!$this->checkPasswordConfirmation()){
- throw new exception("De update is niet correct verlopen. Check alles nog eens");
- }
- $stmt = $PDO->prepare("UPDATE users SET email= :email WHERE usersid = :usersid");
- $stmt->bindValue(":usersid", $userid, PDO::PARAM_INT );//update username met " " "
- $stmt->bindValue(":email", $this->m_sEmail, PDO::PARAM_STR); //aleen email
- $stmt->execute();
- echo("email");
- }
- if (!empty($this->m_sPassword)){
- if(!$this->checkPasswordConfirmation()){
- throw new exception("de update lukt niet, beide passwoorden komen niet overeen.");
- }
- $stmt = $PDO->prepare("UPDATE users Set password = :password WHERE usersid = :usersid");
- $stmt->bindValue(":usersid", $userid, PDO::PARAM_INT );//update password met " " "
- $stmt->bindValue(":password", $this->m_sPassword, PDO::PARAM_STR); //aleen u password
- $stmt->execute();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement