

if(empty($_POST['step']))
{
?><form action="?" method="POST">
<input type="text" name="a_field">
<input type="hidden" name="step" value="2">
<input type="submit"></form><?
}
if($_POST['step'] == "2")
{
$filename = 'data.txt';
$somecontent = $_POST['a_field']."\n";
$handle = fopen($filename, 'a+');
if (fwrite($handle, $somecontent) === FALSE)
{
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote $somecontent to file $filename";
fclose($handle);
}




