Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_POST["firstname"])) {
- $commFile = fopen("comments.txt", "at");
- fwrite($commFile, $_POST["firstname"]." : ".$_POST["comment"]."\n");
- fclose($commFile);
- }
- $comm_file = file_get_contents("comments.txt");//файл базы
- fclose($commFile);
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title>File write Form Test</title>
- </head>
- <body>
- <form name="commentform" action="index.php" method="post">
- <table>
- <tr>
- <td>Имя:</td><td><input type="text" name="firstname"/></td>
- </tr>
- <tr>
- <td>Ваш комментарий:</td><td><textarea name="comment" cols="25" rows="10" value="Comment"></textarea></td>
- </tr>
- <tr><td><br/><input type="submit" name="submitbutton" value="Отправить"/></td></tr>
- </table>
- </form>
- <table>
- <?php
- if (file_exists("comments.txt")) {
- $commFile = fopen("comments.txt", "r" );
- if (!feof($commFile)) {
- fclose($commFile);
- echo $comm_file;
- }
- }
- ?>
- </table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement