Example #1
0
 public function delete()
 {
     if (!\Utils::isUserLogged()) {
         header('Location: /index.php?page=Pages&action=notlogged');
         die;
     }
     if (!empty($_POST)) {
         $id = $_POST['id'];
         $stmt = Ubermodel::$pdo->prepare('DELETE FROM posts WHERE id = ' . $id);
         $stmt->execute();
         header('Location: /index.php?page=Posts');
         die;
     }
 }
Example #2
0
        </td>

        <td>
            <?php 
    echo $x['body'];
    ?>
        </td>

        <td>
            <?php 
    echo $x['created'];
    ?>
        </td>

        <?php 
    if (\Utils::isUserLogged()) {
        ?>
        <td>
            <a class="btn btn-primary" href=<?php 
        echo 'index.php?page=Posts&action=edit&id=' . $x['id'];
        ?>
 >Edit</a>
        </td>
        <td>
            <form role="form" action="index.php?page=Posts&action=delete" method="post">
                <input type="hidden" name="id" value=<?php 
        echo $x['id'];
        ?>
 />
                <button onclick="return confirm('Delete This Post?')" type="submit" class="btn btn-danger">Delete</button>
            </form>