Hi,歡迎訪問前端老白
<form method="post" action="save.php"> <textarea name="content" rows="10" cols="50"></textarea> <input type="submit" value="提交"> </form>
<p> <?php $content = $_POST['content']; // 這里可以將$content保存到數據庫或文件中 echo "保存成功!"; ?> </p>
<p> <?php $content = $_POST['content']; $file = 'user_comments.txt'; $content_to_save = $content . "\n"; file_put_contents($file, $content_to_save, FILE_APPEND); echo "評論已經成功保存!"; ?> </p>
CREATE TABLE comments ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, content TEXT NOT NULL )
<p> <?php $content = $_POST['content']; $sql = "INSERT INTO comments (content) VALUES ('$content')"; if ($conn->query($sql) === TRUE) { echo "評論已經成功保存!"; } else { echo "存儲錯誤: " . $sql . "<br>" . $conn->error; } $conn->close(); ?> </p>
老白網絡 (http://52shenghuonet.cn/) 前端 后端 zblog主題.網站地圖xml