Heh
Coded this in 15mins, So Post back if you get any Errors
3 Files
1) test.html
2) test.php
3) text.txt
test.html
PHP Code:
<form action="test.php" method="post">
<input type="text" name="tbName" /><br />
<input type="submit" name="btnSubmit" value="Submit" />
</form>
test.php
PHP Code:
<?php
//Check if the Form is Posted
if (isset($_POST))
{
$success = false;
//Validate the Fields
if ((isset($_POST['tbName']) && $_POST['tbName'] != '') &&
(isset($_POST['btnSubmit']) && $_POST['btnSubmit'] == 'Submit'))
{
$fcontents = file_get_contents('./text.txt'); //Get the Contents of the File
if (is_writable('./text.txt')) //Check if the File is Writable
{
//Open the File and fput the contents. (Don't forget to add CR+LF)
$fp = @fopen('./text.txt', 'w');
@fputs($fp, $fcontents);
@fputs($fp, $_POST['tbName']);
@fputs($fp, "\r\n");
@fclose($fp);
$success = true; //Set Success Boolean to true
}
else
{
echo 'File not Writable';
}
//If Success is true, then Redirect to a Different Page
if ($success)
{
$redir_page = './test.html'; //Can be set to http://gmail.com/, etc.
header('Location: ' . $redir_page);
}
}
else
{
echo 'Please Fill all the Fields';
}
}
?>
text.txt
(Don't forget to add a blank like at EOF)
The script maybe a little inefficient, but it can be modified
(Yeh! I had some time to waste

)