I created an HTML form to update my posts. So I used header() function to redirect the page to Updated page so I can see the changes. But I wanna echo a message on the redirected page. I have tried this code but this works only on same page, not redirected page.
<?php
$query_2 = "UPDATE posts SET post_image = '$post_image' WHERE post_id = $post_id ";
$query_2 .= "AND LENGTH('$post_image') > 0 AND post_image <> '$post_image' ";
$editPostImg = mysqli_query($connection, $query_2);
if (!$editPostImg) {
die("Something went wrong.<br>" . mysqli_error($connection));
}
header("Location: posts.php?source=edit_posts&p_id=$post_id");
echo "<p class='alert alert-success'><strong>Post Updated!</strong> <a href='../post.php?p_id=$post_id' class='alert-link' target='blank'>View Post</a><a href='' class='close' data-dismiss='alert'>x</a></p>";
}
?>
Post Updated! View Postx
";` on the `posts.php` page, where you are trying to redirect at the beginning. – Serghei Leonenco May 28 '20 at 06:14