Problem with fwrite
| From: | Reuben D Budiardja | Date: | Sat, 18 Nov 2000 19:43:47 +0000 |
| Subject: | Problem with fwrite | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-26073@lists.php.net to get a copy of this message | ||
I have a simple FORM with one textbox. I want to write (append) to a file
the string people put in the textbox. However, the string is always
written double in the file. For example, if I put YAHOO in the textbox,
the file will contain:
YAHOO
YAHOO
Why is that? Any help will be greatly appreaciated. I'm using php4,
apache, redhat linux.
Below is my code.
<?
if(isset($words))
{
$words = $words ."\n";
$fw = fopen('file.txt', 'a');
fwrite($fw, $words);
unset($words);
fclose($fw);
}
echo "<HTML>";
echo "<HEAD>";
echo "<TITLE>Reuben-Audy Chat</TITLE>";
echo "</HEAD>";
echo "<BODY>";
echo "<P>";
echo "<FORM ACTION=\"fwrite.php3?\" METHOD=\"POST\">";
echo "<INPUT TYPE=TEXT NAME=\"words\" OnChange=\"submit();\">";
echo "</FORM>";
echo "</P>";
echo "</BODY></HTML>";
?>
Thanks for any help
Reuben D. Budiardja