Guest User

PHP write POST to file

a guest
Jan 24th, 2019
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. if (isset($_POST) && isset($_POST["text"]) && isset($_POST["filename"])) {
  2. $myfile = fopen($_POST["filename"].".txt", "w") or die("Unable to open file!");
  3. $txt = $_POST["text"];
  4. fwrite($myfile, $txt);
  5. fclose($myfile);
  6. } else {
  7. die('either text or filename isn\'t set');
  8. }
Advertisement
Add Comment
Please, Sign In to add comment