I am very new to php just starting learning from internet. I seen some examples for file handling. But when I'm following the same procedure to file writing it's not working.
The Reading function is working file. But writing to a file isn't working. I have also tried to use file_put_content function to write. :(
<?php
if(isset($_POST['submit1'])){
$fileName = "Text.txt";
$fh = fopen($fileName,"a") or die("can not open the file to write");
//Writing to a file
$newData = "Hello This is new Data";
fwrite($fh,$newData);
fclose($fh);
//Reading a file -- Working
$text = fopen("Text.txt","r") or die ("can not open the file to read");
while(!feof($text))
{
$myLine = fgets($text);
print $myLine;
}
fclose($text);
}
?>
Please Guide me.. Thanks
chmod). But be careful, don't go around and give everything all rights to everything. This will create a big security risk!file_put_contents, with ansat the end. Also read this since you're new, there's no point in learning bad practices