protected function deleteaccount()
 {
     //do something
     global $rep, $view;
     $data = array();
     if (isset($_POST['confirmdelete'])) {
         //we edit
         $pwd1 = $_POST['pwd1'];
         $pwd2 = $_POST['pwd2'];
         if (checkData::checkBothPassword($pwd1, $pwd2)) {
             $usr = $_SESSION['username'];
             if (userModel::getUser($usr, $pwd1) != NULL) {
                 session_unset();
                 session_destroy();
                 userModel::deleteUser($usr);
                 $_REQUEST['action'] = NULL;
                 header('Location: index.php');
             } else {
                 $data['error'] = 'You typed the wrong password';
             }
         } else {
             $data['error'] = 'The password don\'t match!';
         }
     }
     require_once $view['deleteaccount'];
 }
Ejemplo n.º 2
0
 public function deleteUser()
 {
     $userID = $_POST['userID'];
     $userModel = new userModel();
     $status = true;
     $msg = "user deleted successfully";
     $result = $userModel->deleteUser($userID);
     if (!$result) {
         $status = false;
         $msg = "user deleted unsuccessfully";
     }
     $resultArray = array('status' => $status, 'msg' => $msg);
     echo json_encode($resultArray);
 }