Gitlab@Informatics

Skip to content
Snippets Groups Projects
Select Git revision
  • 1f127d961a2de9bb0a9ebec20e1d01769935adde
  • main default protected
  • master
3 results

view_post.php

Blame
  • view_post.php 8.32 KiB
    <?php
    
    include 'components/connect.php';
    
    if(isset($_GET['get_id'])){
       $get_id = $_GET['get_id'];
    }else{
       $get_id = '';
       header('location:all_posts.php');
    }
    
    if(isset($_POST['delete_review'])){
    
       $delete_id = $_POST['delete_id'];
       $delete_id = filter_var($delete_id, FILTER_SANITIZE_STRING);
    
       $verify_delete = $conn->prepare("SELECT * FROM `reviews` WHERE id = ?");
       $verify_delete->execute([$delete_id]);
       
       if($verify_delete->rowCount() > 0){
          $delete_review = $conn->prepare("DELETE FROM `reviews` WHERE id = ?");
          $delete_review->execute([$delete_id]);
          $success_msg[] = 'Review deleted!';
       }else{  
          $warning_msg[] = 'Review already deleted!';
       }
    
    }
    
    ?>
    
    <!DOCTYPE html>
    <html lang="en">
    <head>
       <meta charset="UTF-8">
       <meta http-equiv="X-UA-Compatible" content="IE=edge">
       <meta name="viewport" content="width=device-width, initial-scale=1.0">
       <title>view post</title>
    
       <!-- custom css file link  -->
       <link rel="stylesheet" href="css/style.css">
    
    </head>
    <body>
       
    <!-- header section starts  -->
    <?php include 'components/header.php'; ?>
    <!-- header section ends -->
    
    <!-- view posts section starts  -->
    
    <section class="view-post">
    
       <div class="heading">
          <h1>post details</h1> 
          <a href="all_posts.php" class="inline-option-btn" style="margin-top: 0;">all posts</a>
       </div>
    
       <?php
          $select_post = $conn->prepare("SELECT * FROM `posts` WHERE id = ? LIMIT 1");
          $select_post->execute([$get_id]);
          if($select_post->rowCount() > 0){
             while($fetch_post = $select_post->fetch(PDO::FETCH_ASSOC)){
    
            $total_ratings = 0;
            $rating_1 = 0;
            $rating_2 = 0;
            $rating_3 = 0;
            $rating_4 = 0;
            $rating_5 = 0;