...

View Full Version : File writing problem



Kura_kai
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


<html>
<head>
</head>
<body align='center'>
<center>
<iframe src='filer.php' width='95%' height='85%' name="as">
</iframe>
<br>
<table width='95%'>
<tr>
<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'>
<br>
</form>
</td>
</tr>
</table>
</body>
</html>
<?php
$name=$_COOKIE["name"];
if(isset($_POST["msg"]))
{
$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";
?>

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum