HTML表單提交后,要怎么寫php端語言才能保存到txt文本中呢?比如,我的服務器現在根目錄有index.php, ? save.txt, ? welcome.php ? 三個文件,index.php中代碼是這樣的<html>
<body>
<form?action="welcome.php"?method="post">
Name:?<input?type="text"?name="name"><br>
E-mail:?<input?type="text"?name="email"><br>
<input?type="submit">
</form>
</body>
</html>我要在welcome.php中怎么寫才能把用戶提交的數據保存到save.txt中?謝謝大家,我比較笨
2 回答

風之子ccf
TA貢獻9條經驗 獲得超19個贊
首先接收post過來的參數
$post = $_POST;
對$post轉化成json或者做序列化(選一個)
$new_post = json_encode($post); ? //轉為json
$new_post = serialize($post); ?//序列化
存入save.txt(你最想知道的一步)
file_put_contents('./save.txt',$new_post,FILE_APPEND);
That`s all ! ?
- 2 回答
- 2 關注
- 2207 瀏覽
相關問題推薦
添加回答
舉報
0/150
提交
取消