0

Inline Code Example HereHi,
the php code which

<html>
<body>
<?php 
$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,$message);
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 />";
}
fclose($fs);
/*<html>
<body onLoad="location.href='#chini'">
//<a name="chini"> </a>
</body>
</html>
*/
?>
</body>
</html>

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.
Regards

2
Contributors
1
Reply
4
Views
5 Years
Discussion Span
Last Post by diafol
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.