View Full Version : File writing problem

06-18-2005, 01:00 AM
I am having problems developing my chat program. What i want it to do is write to the begining of the file while trying to keep the rest. But so far it manages to delete the rest somehow. here is my code rightnow

<body align='center'>
<iframe src='filer.php' width='95%' height='85%' name="as">
<table width='95%'>
<td align='center' width='100%'>
<form action='chat.php' method='post' name='m'>
Message : <input name='msg' size=60><input type='submit' name='send' value='Send'>
$msg = $_POST["msg"];
$file = "file.txt";
$msg4 = $name . ":" . $msg . "\n";
$msg3 = str_replace("<", " &lt; ", "$msg4");
$msg2 = str_replace(">", " &gt; ", "$msg3");
$fp = fopen ($file, 'r+');
$contents = fread($fp, filesize($filename));
fclose ($fp);
$fp = fopen ($file, 'w+');
fwrite ($fp, $msg2);
fwrite ($fp, $contents);
fclose ($fp);
Echo "Please Input a Message";

06-18-2005, 01:07 AM
this may be to late but forget what i just said i found a way to have the scroller go down to the very bottom. Sorry to any one who was working on this.