Hi,
I am trying to create a very simple php script that will:
- Collect data from a form
- Place data in a CSV file
- Display data from the file on a page
- Replace old data with new data if form is filled in again.
I have the following script:
<?php
@extract($_POST);
if(is_writable('file.csv'))
{
$fp = fopen('file.csv','a');
$content = "$lastname,$firstname,$email,$format,$date\n";
fwrite($fp,$content);
fclose($fp);
}
else
{
echo'File is not writable';
}
?>
This is placing the data in the csv file....however...if I use the form again...it add the new data. I want it to replace the data. Can you help me figure out what I need to tweak in my script?
Also, how do I pull the data out of the csv file?
Thanks