textinput.php 818 B

12345678910111213141516171819202122232425262728293031323334
  1. <html>
  2. <body>
  3. <?php
  4. $saving = $_REQUEST['saving'];
  5. if ($saving == 1){
  6. $data = $_POST['data'];
  7. $unique = rand(1, 10000);
  8. $file = "text".$unique.".txt";
  9. $fp = fopen($file, "w") or die("<p>Couldn't open $file for writing!</p>");
  10. fwrite($fp, $data) or die("<p>Couldn't write values to file!</p>");
  11. fclose($fp);
  12. echo "<p>Saved to $file successfully! You may now use $file as a text input for your program.</p>";
  13. }
  14. ?>
  15. <p>
  16. <form name="form1" method="post" action="?saving=1">
  17. Write your text here:
  18. <br>
  19. <textarea name="data" cols="50" rows="10">
  20. This is the file you can use to provide input to your program and later on open it inside your program to process the input.
  21. </textarea>
  22. <br>
  23. <input type="submit" value="Save">
  24. <br>
  25. <br>
  26. <a href="output.php">Click here to close text input</a>
  27. </form>
  28. </p>
  29. </body>
  30. </html>