neo_philiac
06-11-2008, 05:45 PM
Very simple question i have this code
<?php
$Handle = fopen("file.txt", "a+") or
die( "Error opening file" );
if (!fwrite($Handle, $_POST['addition'] . "\n"))
{
die( "Error writing to file!" );
}
fclose($Handle) or
die( "Error closing file!" );
?>
<form action="<?=$PHP_SELF?>" method="post">
<input type="text" name="addition"/><br/>
<input type="submit"/>
</form>
To append string into a text file with a newline. So, now if you see the text file, it looks like.
Mary
Jane
Mark
How do I get it to increment the last (number +1) every time I append the data :
1 Mary
2 Jane
3 Mark
Thanks
<?php
$Handle = fopen("file.txt", "a+") or
die( "Error opening file" );
if (!fwrite($Handle, $_POST['addition'] . "\n"))
{
die( "Error writing to file!" );
}
fclose($Handle) or
die( "Error closing file!" );
?>
<form action="<?=$PHP_SELF?>" method="post">
<input type="text" name="addition"/><br/>
<input type="submit"/>
</form>
To append string into a text file with a newline. So, now if you see the text file, it looks like.
Mary
Jane
Mark
How do I get it to increment the last (number +1) every time I append the data :
1 Mary
2 Jane
3 Mark
Thanks