Example #1
0
 /**
  * Выполняет операцию над отмеченными пользователями в админке.
  * @return boolean
  */
 public function operationUser()
 {
     $operation = $_POST['operation'];
     if (empty($_POST['users_id'])) {
         $this->messageError = 'Необходимо отметить пользователей!';
         return false;
     }
     if ($operation == 'delete') {
         foreach ($_POST['users_id'] as $userId) {
             $del = USER::delete($userId);
             if (!$del) {
                 $this->messageSucces = 'Удалены отмеченные пользователи, кроме администратора!';
             }
         }
     }
     $this->messageSucces = 'Выделенные пользователи удалены!';
     return true;
 }
Example #2
0
    //runs a query depending on the id of the post
    $query = $conn->prepare("SELECT userID, title FROM blogpost WHERE blogID = :blogID");
    $query->execute(array(":blogID" => $blogID));
    $row = $query->fetch(PDO::FETCH_ASSOC);
    //if no results, display "Oh,no!"
    if ($row == "") {
        echo "OH NO";
    } else {
        //setting variables
        $userIdent = $row['userID'];
        $title = $row['title'];
    }
    if (isset($_POST['delete'])) {
        //if no errors are found, run update
        if ($userID == $userIdent) {
            $user->delete($blogID);
            $submitted[] = "Deleted! Now wasn't that easy?";
        }
    }
} catch (PDOException $e) {
    echo "Error: " . $e->getMessage();
}
/*
//when the post has been changed and the user clicks update
*/
?>

<?php 
//but we also check if the user is the right user
if ($userID == $userIdent) {
    ?>