php實現簡單記事本功能
阿新 • • 發佈:2019-01-01
首先先做個html網頁表單
程式碼=》
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form action="01.php"method="post">
<p>留言標題<input type="text"name="title"></p>
<p>留言內容<textarea name="content"id="" cols="30" rows="10" ></textarea></p>
<p><input type="submit"value="提交"></p>
</form>
</body>
</html>
然後做個名字為01.php的php檔案,用來接收資料並且傳到文字儲存,程式碼=》
<?php
$str="標題:".$_POST["title"].",內容:".$_POST["content"]."\n";
$fh=fopen("./msg.txt","a");
fwrite($fh,$str);
fclose($fh);
echo"ok";
?>
這樣就完成了這個簡單的記事本功能