Advertisement
Guest User

Untitled

a guest
Nov 18th, 2011
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. <?php
  2. if (isset($_POST['submit'])) {
  3.  
  4. $myFile = "123.html";
  5. $fh = fopen($myFile, 'w') or die("can't open file");
  6. $stringData = stripslashes($_POST['sf']);
  7. fwrite($fh, $stringData);
  8. fclose($fh);
  9.  
  10. header('Location: editer.php?a=done');
  11.  
  12. }
  13. ?>
  14.  
  15. Inside body:
  16. <form action="" method="post">
  17. <textarea name="sf" cols="40" rows="6">
  18. <?php
  19. $myFile = "123.html";
  20. $fh = fopen($myFile, 'r');
  21. $theData = fgets($fh);
  22. fclose($fh);
  23. echo $theData;
  24. ?></textarea>
  25. <br />
  26. <input type="submit" name="submit" value="Edit" />
  27. </form>
  28.  
  29. <?php
  30. if ($_GET['a'] == 'done') {
  31. echo 'The file was saved and now it says:<br /><br />';
  32.  
  33. $myFile = "123.txt";
  34. $fh = fopen($myFile, 'r');
  35. $theData = fgets($fh);
  36. fclose($fh);
  37. echo $theData;
  38.  
  39. }
  40. ?>
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement