Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. if (isset($_POST["firstname"])) {
  5. $commFile = fopen("comments.txt", "at");
  6.  
  7. fwrite($commFile, $_POST["firstname"]." : ".$_POST["comment"]."\n");
  8.  
  9. fclose($commFile);
  10. }
  11. $comm_file = file_get_contents("comments.txt");//файл базы
  12. fclose($commFile);
  13. ?>
  14.  
  15.  
  16. <!DOCTYPE html>
  17. <html>
  18. <head>
  19. <title>File write Form Test</title>
  20. </head>
  21. <body>
  22.  
  23. <form name="commentform" action="index.php" method="post">
  24. <table>
  25. <tr>
  26. <td>Имя:</td><td><input type="text" name="firstname"/></td>
  27. </tr>
  28. <tr>
  29. <td>Ваш комментарий:</td><td><textarea name="comment" cols="25" rows="10" value="Comment"></textarea></td>
  30. </tr>
  31. <tr><td><br/><input type="submit" name="submitbutton" value="Отправить"/></td></tr>
  32. </table>
  33. </form>
  34. <table>
  35. <?php
  36.  
  37. if (file_exists("comments.txt")) {
  38. $commFile = fopen("comments.txt", "r" );
  39.  
  40. if (!feof($commFile)) {
  41.  
  42. fclose($commFile);
  43.  
  44. echo $comm_file;
  45. }
  46. }
  47. ?>
  48. </table>
  49. </body>
  50. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement