fopen and r+ problem
- From: s1m0n <nomail@xxxxxxxxxxxx>
- Date: Wed, 12 Sep 2007 18:24:06 +0200
Hi everybody,
I would like to write a simple code to add some text at the begining of a file without erase the other data.
in my file:
news4
news3
news2
news1
if I want to add the text "news5!", the file will look like this:
news5!
news4
news3
news2
news1
So I wrote this:
<?php
if (isset($HTTP_POST_VARS['go'])) {
$content = "\r\n" . $HTTP_POST_VARS['news'] . "<br />";
$write = fopen('news.ini', 'r+');
fwrite($write, $content);
fclose($write);
?>
<form action="" method="post">
<input type="text" name="news" size="28" /><input type="submit" name="go" value="Go" />
</form>
<?php
} else {
?>
<form action="" method="post">
<input type="text" name="news" size="28" /><input type="submit" name="go" value="Go" />
</form>
<?php
}
?>
But this code doesn't work, everything is erase in my file, no new line appears...
Could you please help me ?
Thank you, and hope my english is understandable.
--
++
Simon
--------
http://latox.free.fr/3d/
.
- Follow-Ups:
- Re: fopen and r+ problem
- From: J.O. Aho
- Re: fopen and r+ problem
- From: Good Man
- Re: fopen and r+ problem
- Prev by Date: Re: How to insert HTML Tags into PHP codes..
- Next by Date: Re: fopen and r+ problem
- Previous by thread: who help me make archive.php
- Next by thread: Re: fopen and r+ problem
- Index(es):