problem with $insertcode
Posted: Sun Nov 23, 2003 9:39 pm
i wrote a script to process a form and write the given fields to a flat file (text file), the problem i'm having is every time i try to use the script to add something to the txt file, it overwrites the contents of the entire file.
Code: Select all
<?php
if((!isset($_POST['name'])) or (!isset($_POST['link'])) or (!isset($_POST['info'])))
{
echo 'You must enter <b>ALL</b> fields before you can continue!';
exit;
}
$name = $_POST['name'];
$link = $_POST['link'];
$info = $_POST['info'];
$fp = fopen("download.txt", "w+");
$insertcode = "<table width='100%' border='0' cellspacing='1' cellpadding='2' bgcolor='#dcdcdc' align='center'><tr><td width='200' border='1' bgcolor='whitesmoke'>".$name." - <a href='/files/".$link."'>download</a></td></tr><tr><td width='200' border='1' bgcolor='#ffffff'>".$info."</td></tr></table>";
fwrite($fp, $insertcode);
fclose($fp);
?>