<?php
  
  $saved = false;
  //print_r($_POST);
  if (isset($_POST["save"])){
    //save the textarea to the file
    //make sure to set file permissions to 777
    $file =fopen("data/home.html", "w") or die("check permissions");
    
    //remove slashes that were added when post occurred
    fwrite($file, stripslashes($_POST["content"]));
    fclose($file);
    $saved = true;
  }
  
  ?>


<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>CMS</title>
  
  <style>
    textarea{
      width:500px;
      height:400px;
      resize: none;  
    }
  </style>
</head>
  
  
<body>

  <?php
  
  if ($saved){
    echo "Your file was saved...";
  }
  
  ?>
  <form method="post" action="home.php">
   
    
    <textarea id="content" name="content"><?php
  $file =file_get_contents("data/home.html");
  echo $file;
  ?></textarea>
    
  
    
    <input type="submit" name="save" value="SEND TO HOMEPAGE!" />
  </form>
  
  
</body>
</html>