A rather complicated scenario. Blog script post.php, has a form to submit comment to article title that was clicked on and is displayed to user. This is the form portion of script:
$id = (int) $_GET['id']; //at beginning of script - obtained from title clicked on by user
<form action="post.php?id=<?php echo $id; ?>" method="post">
<?php
if ($logged == 'No') {
$guest = 'Yes';
?>
<label for="name"><i class="fa fa-user"></i> Your Name:</label>
<input type="text" name="author" value="" class="form-control" required />
<br />
<?php
}
?>
<label for="input-message"><i class="fa fa-comment"></i> Comment: (255 character limit including spaces and punctuation)</label>
<textarea id="mylmnt" maxlength="255" name="message" rows="5" class="form-control" required></textarea>
<b><span id="mylmntLeft"></span></b>
<br />
And this is the db insert portion of script:
$runq = mysqli_query($connect, "INSERT INTO `comments` (`post_id`, `comment`, `user_id`, `date`, `time`, `guest`) VALUES ('$row[id]', '$comment', '$author', '$date', '$time', '$guest')");
echo '<div class="alert alert-success">Your comment has been successfully posted</div>';
After this is my html template to send emails to subscribers that a new comment has been posted. This all works fine. After my template there is this line:
}
echo '<meta http-equiv="refresh" content="0;url=post.php?id=' . $row['id'] . '#comments">';
This refreshes the post.php page and jumps down the the #comment section. My problem is that the new comment that was just posted is not showing. The only way so far to see it is to hit browser reload button. I know that to accomplish what I need I have to use ajax and jquery but I have no idea how to do that and where things should go. I've read and studied many many tutorials and code postings but none of it has helped me to even get started with a solution.
I've tried window.location.reload(); and window.location.reload(true); which hasn't worked. As I've already said I have no idea how to use ajax and jquery to solve this.