I want my php file to write some text to a text file that I have created but nothing is being written to it.
Here is the code:
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
if (isset($_POST['comment']))
{
$comment = $_POST['comment'];
$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $comment;
fwrite($fh, $stringData);
fclose($fh);
}
else
{
$comment = 'no comment';
$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $comment;
fwrite($fh, $stringData);
fclose($fh);
}
?>
Check the file permissions.
Try changing permission if that was the issue: