如何写一页极简的“笔记本”网页,基于 PHP

303 天前
 lewiet

类似 note.ms 但极简,就一页,打开就显示后台的一个 TXT 文本内容, 然后网页上可修改内容,保存更改到后台 TXT 文件

<html> <head> <title>My Notes</title> </head> <body>

My Notes

<form method="post"> <textarea name="note" rows="10" cols="50"></textarea>
</form>
<?php
	if(isset($_POST['save'])) {
		$note = $_POST['note'];
		$file = fopen("my_note.txt", "w") or die("Unable to open file!");
		fwrite($file, $note);
		fclose($file);
		echo "<p>Note saved successfully!</p>";
	}
?>

<h2>Edit Note</h2>
<form method="post">
	<textarea name="note" rows="10" cols="50"><?php echo file_get_contents("my_note.txt"); ?></textarea><br>
	<input type="submit" name="save" value="Save">
</form>
</body> </html>
1524 次点击
所在节点    PHP
16 条回复
baiduyixia
303 天前
??
Soar360
302 天前
这个实现非常的简洁。
dddys
302 天前
可以
solopython
302 天前
data:text/html,<html contenteditable>
试试这个,以上代码放到浏览器地址栏
lizhenda
302 天前
这还要用 PHP ???
redsun368573607
302 天前
你这个 submit 还被显示了就离谱
ellermister
302 天前
这个 submit 离谱,有趣!

我也想写一个简易的笔记分享网页!
SparkQiu
302 天前
谢谢分享的创意!
配合上弹出层,很具有实用性,已经实现并用上了。
zhishixiang
302 天前
怎么连 xss 注入都来了
zhishixiang
302 天前
lewiet
302 天前
@solopython 不太明白,详说。。
@redsun368573607 哈,V2EX 自动激活。。
@zhishixiang 新手,各位请改正,指教,分享给大家

本意就是有一个在线记事本,记一些常用的网址密码。。随手拿来用,现成的各种 PASTEBIN 都太大太臃肿。
我也不太满意,请大家修改补充完善。。。
lewiet
302 天前
还有就是可以 0 成本部署在一个只有自己知道的 URL ,连密码都省了
redsun368573607
298 天前
@zhishixiang 插了一个 submit 而已,js 应该插不了
xiaokeplus
289 天前
这网站没有 htmlspecialchars...
xiaokeplus
289 天前
<script>alert(1);</script>
@xiaokeplus
g001
225 天前
<html>
<head>
<title>My Notes</title>
</head>
<body>
<h1>My Notes</h1>
<form method="post">
<textarea name="note" rows="10" cols="50"></textarea><br/>
<script>alert(/1/)</script>
</form>
<?php
if(isset($_POST['save'])) {
$note = $_POST['note'];
$file = fopen("my_note.txt", "w") or die("Unable to open file!");
fwrite($file, $note);
fclose($file);
echo "<p>Note saved successfully!</p>";
}
?>

<h2>Edit Note</h2>
<form method="post">
<textarea name="note" rows="10" cols="50"><?php echo file_get_contents("my_note.txt"); ?></textarea>
<input type="submit" name="save" value="Save">
</form>
</body>
</html>

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/955870

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX