textinput.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <html>
  2. <body>
  3. <?php
  4. $saving = $_REQUEST['saving'];
  5. if ($saving == 1)
  6. {
  7. $data = $_POST['data'];
  8. $unique = rand(1, 10000);
  9. $file = "text".$unique.".txt";
  10. $fp = fopen($file, "w") or die("<p>Couldn't open $file for writing!</p>");
  11. fwrite($fp, $data) or die("<p>Couldn't write values to file!</p>");
  12. fclose($fp);
  13. echo "<p>Saved to $file successfully! You may now use $file as a text input for your program.</p>";
  14. }
  15. /* Code for taking text input. Similar to the first part of output.php */
  16. ?>
  17. <p>
  18. <form name="form1" method="post" action="?saving=1">
  19. Write your text here:
  20. <br>
  21. <!-- Text box to take text input for program -->
  22. <textarea name="data" cols="50" rows="10">
  23. 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.
  24. </textarea>
  25. <br>
  26. <!-- Submit button goes here -->
  27. <input type="submit" value="Save">
  28. <br>
  29. <br>
  30. <!-- Link to close text input -->
  31. <a href="output.php">Click here to close text input</a>
  32. </form>
  33. </p>
  34. </body>
  35. </html>