# PHP fputs function

**URL:** <https://forum.kirupa.com/t/php-fputs-function/144429>\
**Category:** Uncategorized\
**Created:** [April 14, 2005, 7:30am UTC](https://forum.kirupa.com/t/php-fputs-function/144429 "2005-04-14T07:30:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![motox\_matt](https://avatars.discourse-cdn.com/v4/letter/m/a183cd/32.png) [@motox\_matt](https://forum.kirupa.com/u/motox_matt)\
**Post date:** [April 14, 2005, 7:30am UTC](https://forum.kirupa.com/t/php-fputs-function/144429/1 "2005-04-14T07:30:51Z")

</div>

hi all, i have a simple php program which writes some data retrieved from a form to a text document. My problem is that when i run the script the data overwrites the previous data. i was wondering how to get around this. any help would be appreciated. The script looks like this

$details = “details.txt”;  
$det = file($details);  
$det[0] = $\_POST[“first”];  
$one = $det[0];  
$det[1] = $\_POST[“second”];  
$two = $det[1];  
$det[2] = $\_POST[“age”];  
$three = $det[2];

$opened = fopen($details , “w”);  
fputs($opened , “$one”);  
fputs($opened , “$two”);  
fputs($opened , “$three”);  
fclose($opened);
