Skip to content

Instantly share code, notes, and snippets.

@mattdodge
Created June 20, 2012 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattdodge/2961671 to your computer and use it in GitHub Desktop.
Save mattdodge/2961671 to your computer and use it in GitHub Desktop.
Simple PHP File Editor
<?php
$the_file = "file.txt";
if (isset($_POST['content'])) {
$content = stripslashes($_POST['content']);
$fp = fopen($the_file,"w") or die ("Error opening file in write mode!");
fputs($fp,$content);
fclose($fp) or die ("Error closing file!");
}
?>
<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post">
<textarea rows="45" cols="80" name="content"><?php readfile($the_file); ?></textarea>
<input type="submit" value="Save">
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment