On my primary page, Ive decided to not constantly update the file with news and info and upload it as this will be too much hastle. So ive created a file called news.php which contains the news headlines with HTML code and linked it to the index.php.
In a secure folder on my server, ive created a sort of 'update news' page with the following php code:
<?php
$file = file_get_contents("news.php");
echo '<textarea name="textarea2" cols="100" rows="10">' . $file . '</textarea>';
?>
This opens up the news.php file into a textarea. I have added an update button below but do not know how to code it. The page opens and the news.php file loads into the textarea with no problems. My plan is that I can edit the file to update the news and click the update button and have the edited text in the textarea over right the current stuff. Ive found some examples online but dont know how to incorporate it. One example is:
<?php
$File = "YourFile.txt";
$Handle = fopen($File, 'w');
$Data = "John Henry\n";
fwrite($Handle, $Data);
$Data = "Abigail Yearwood\n";
fwrite($Handle, $Data);
print "Data Written";
fclose($Handle);
?>
Is this the kinda thing I need? If so, how do I encorporate it into my update page?