Without knowing your full requirements, this should get you started. I imagine you are going to want to store the saved/changed text into a database. If this is the case, you need to build upon what is provided below. Hope this helps.
Enter Text Here…
<?php
if( isset( $_POST['my_text'], $_POST['save'] ) && strlen( $_POST['my_text'] ) > 0 )
{
$my_text = htmlspecialchars( $_POST['my_text'] )."\n";
if( !file_put_contents( 'view.php', $my_text, FILE_APPEND ) )
{
echo "Unable to write to file";
}
else
{
echo "Content Saved";
}
}
elseif( isset( $_POST['my_text'], $_POST['change'] ) && strlen( $_POST['my_text'] ) > 0 )
{
$my_text = htmlspecialchars( $_POST['my_text'] )."\n";
if( !file_put_contents( 'view.php', $my_text ) )
{
echo "Unable to write to file";
}
else
{
echo "Content changed";
}
}
else
{
echo "Please enter some text";
}
?>
solved php How to save post and save show to php file like this [closed]