Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8831439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:18:33+00:00 2026-06-14T08:18:33+00:00

i am writing a comment block in my website. i save the comment in

  • 0

i am writing a comment block in my website.
i save the comment in a file and print the contents on the webpage.
but the problem is when i refresh the webpage the last comment gets displayed twice.

Here’s my code:
i am writing a comment block in my website.
i save the comment in a file and print the contents on

the webpage.
but the problem is when i refresh the webpage the last

comment gets displayed twice.

Here’s my code:

<html>


<body>

<form   method="GET">

<textarea rows="15" cols="50" name="comments" >
</textarea>

<input type="submit" value="submit" >

</form>

</body>
</html>



<?php


if(!($_GET["comments"]==null)){
$comments = "Anonymous said:<br>".$_GET

["comments"]."<br><br><br><br>";
$file_comments = fopen("comments.txt","a");
fwrite($file_comments,$comments);
fclose($file_comments);

$_GET["comments"] = null;
$comments = null;

}


$comments = file_get_contents("comments.txt");
echo $comments;


$_GET["comments"] = null;
$comments = null;

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:18:34+00:00Added an answer on June 14, 2026 at 8:18 am

    Here are quick solutions:

    1. After your form has been saved or if it has an error, redirect them to the same page but with GET variables in the uri like process.php?action=save. Use header function for redirection.

    2. You also use cookies to save the IP of the person who submits the form and restrict him for certain period to be able to submit the form again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am developing a website on writing reports ...users can comment on a report
Background I'm writing an asynchronous comment system for my website, after reading plenty of
I am writing this comment class: class Comment { public $id; public $post_id; public
I am writing to clarify some comments on this website. 1) I know that
I am writing a recursive function to print out the differences between 2 multildimensional
I'm writing a comment system. It has to be have formatting system like stackoverflow's.
I am writing a network server in java, and I have a tiny problem
There seem to be endless pages of writing and comment threads about addEvent implementations
I have a asp.net page I'm writing and I'm perplexed by this problem. I
Yeah, so I have NO CLUE what happened. I've been writing an AJAX comment

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.