mlukac89 Posted February 28, 2014 Share Posted February 28, 2014 Hey all, I have some problems with this script when i post a comment and try to refresh page in Firefox it re-send data, but in Chrome and Opera is not re-send this is all in comments.php and i include it in other file <h4 class="h3-title">Comments</h4><small><?php if (!isset($_SESSION['username'])) { echo 'You must be looged in to post comments'; } ?></small> <hr /> <?php // list all comments if (isset($_GET['id'])) { $id = (int)$_GET['id']; $list_all_comments = $comments->list_comments($id); foreach ($list_all_comments as $comm) { echo '<i>' . $comm['comment_author'] . ' - <small>' . date('m F Y h.m.s', $comm['comment_date']) . '</small></i><br />'; echo '<p>' . $comm['comment_body'] . '</p><hr />'; } } // show comment form only for logged in users if (isset($_SESSION['username'])) { // process form data if (isset($_POST['comment'])) { if (isset($_GET['id'])) { $news_id = (int)$_GET['id']; $author = $_SESSION['username']; $body = trim(htmlentities($_POST['body'])); $date = time(); if (!empty($body)) { // add_comment($author, $body, $date, $news_id) $insert_comment = $comments->add_comment($author, $body, $date, $news_id); // refresh page after adding data echo '<meta http-equiv="refresh" content="0">'; } } } ?> <form action="" method="POST"> <textarea name="body" cols="75" rows="6" autofocus required></textarea><br /> <input type="submit" name="comment" value="Submit"> </form> <?php } ?> Quote Link to comment Share on other sites More sharing options...
Solution paddy_fields Posted February 28, 2014 Solution Share Posted February 28, 2014 (edited) You should be using a redirect instead of the refresh. change: // refresh page after adding data39. echo '<meta http-equiv="refresh" content="0">'; to: header('location:mypage.php?id='.$news_id); Obviously changing 'mypage.php' to your page name. Edited February 28, 2014 by paddyfields Quote Link to comment Share on other sites More sharing options...
mlukac89 Posted February 28, 2014 Author Share Posted February 28, 2014 Thx alot problem solved Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.