<!-- use to display full post where the see more button is clicked -->
<?php
// Include the database configuration file
include 'config.php';

if (isset($_GET['edit'])) {
  $post_id = $_GET['edit'];
  $update = true;
  $posts = mysqli_query($db, "SELECT * FROM image_upload WHERE id=$post_id");

  
  while  ($read_post = mysqli_fetch_array($posts))
  {
    $new_image = $read_post['image'];
    $new_image_text = $read_post['image_text'];
  }
}

// Initialize message variable
$msg = "";
// If upload button is clicked ...
if (isset($_POST['update'])) {
  $img_id=$_POST['post_id'];
  $img=$_POST['image'];
  $txt=$_POST['image_text'];
  $date=$_POST['date_posted'];

  $sql = "UPDATE image_upload SET image='$img', image_text='$txt', date_posted='$date' WHERE id='$img_id'";
  // execute query
  $update_posts=mysqli_query($db, $sql);
  if($update_posts){
    
    $msg = "Image uploaded successfully";

    header("Location: profile.php");
  } 
  else{
    
    $msg = "Image uploaded not successfully";

    header("Location: profile.php");
  }
}
?>
