Inline Code Example HereHi,
the php code which

$fs =fopen("comments.txt",'a');
$jina = $_POST["fname"];
$message = $_POST["message"];
$time = date("d/m/y : H:i:s", time()) ;
//limit leght characters
//$message = wordwrap($message, 5);
fwrite($fs, "\n<i>Posted By </i> ".$jina." <i>on </i>");
fwrite($fs, $time);
fwrite($fs, "<hr />");
$fs= fopen("comments.txt", 'r');
while (!feof($fs))
echo fgets($fs)."<br />";
<body onLoad="location.href='#chini'">
//<a name="chini"> </a>

writes the contents to the txt file, but the problem is when I click refresh button it writes the data as many times as I refresh the page. how can I avoid it.

Member Avatar

A script like this could be a standalone which then redirects back to the original page.

You could use a flag variable to prevent the code runnign again, e.g. with sessions or use a cookie - but cookies can be turned off.

form page -> filecreator -> form page