Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // If the user is an administrator
- if($_SESSION['is_admin']){
- // And the user want to delete or restore a message
- if(isset($_GET['delete']) or isset($_GET['restore'])){
- // Delete the message associated with the GET parameter "delete"
- if(isset($_GET['delete'])){
- $query = "UPDATE public.chat_message SET deleted = TRUE WHERE message_id = :message_id";
- $query_params = array(':message_id' => $_GET['delete']);
- }
- if(isset($_GET['restore'])){
- // Restore the message associated with the GET parameter "restore"
- $query = "UPDATE public.chat_message SET deleted = FALSE WHERE message_id = :message_id";
- $query_params = array(':message_id' => $_GET['restore']);
- }
- try{
- $stmt = $pdo->prepare($query);
- $result = $stmt->execute($query_params);
- }catch(PDOException $ex){
- // If an unknown error occurred during restore or delete fail early
- echo '<span style="color: red">ERROR! Code: 008</span>';
- exit;
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement