I am trying to create a program to get input from user in textarea and save that input into a text file.
But this code is only creating an empty file.
<?php
echo <<<_END
<form action="form.php" method="post">
<textarea name="textdata" cols="50" rows="20"></textarea>
<input type="submit" name="submit" value="CLICK ME">
<input type="hidden" name="submit_check" value="1">
</form>
_END;
function write(){
$fname="test.txt";
$fh=fopen($fname,'w');
$data=$_POST['textdata'];
fwrite($fname,$data);
fclose($fh);
}
if(isset($_POST['submit_check'])){
write();
}
?>
please help me.
sorry for bad english