<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Google风格留言板</title> <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700"> <style> * { box-sizing: border-box; } body { font-family: 'Roboto', sans-serif; background-color: #f5f5f5; margin: 0; padding: 20px; } .container { max-width: 600px; margin: 0 auto; background-color: #fff; padding: 20px; border-radius: 4px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); } .message { margin-bottom: 20px; padding: 10px; border: 1px solid #ddd; background-color: #fff; border-radius: 4px; } .message .meta { font-size: 12px; color: #777; } .message p { margin: 0; } textarea { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 4px; resize: vertical; } input[type="submit"] { background-color: #4285f4; color: #fff; padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; } input[type="submit"]:hover { background-color: #3367d6; } </style> </head> <body> <div class="container"> <h1>Google风格留言板</h1> <!-- 留言表单 --> <form method="POST" action=""> <textarea name="message" rows="4" placeholder="请输入留言内容"></textarea> <br> <input type="submit" name="submit" value="发布留言"> </form> <?php // 处理表单提交 if (isset($_POST['submit'])) { $message = $_POST['message']; // 存储留言到文件 $file = 'messages.txt'; $current = file_get_contents($file); $current .= "<div class='message'><p>$message</p><p class='meta'>发布时间:" . date('Y-m-d H:i:s') . "</p></div>"; file_put_contents($file, $current); } // 显示留言 $messages = file_get_contents('messages.txt'); echo $messages; ?> </div> </body> </html>
No Comment