lewiet
V2EX  ›  PHP

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

  •  
  •   lewiet · Jul 11, 2023 · 3127 views
    This topic created in 1211 days ago, the information mentioned may be changed or developed.

    类似 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>
    16 replies  •  2023-09-27 03:29:20 +08:00
    baiduyixia
    baiduyixia
    Jul 11, 2023
    1
    ??
    Soar360
    Soar360
    Jul 11, 2023
    2
    这个实现非常的简洁。
    dddys
    dddys
    Jul 11, 2023
    3
    可以
    solopython
    solopython
    Jul 11, 2023❤️1
    4
    data:text/html,<html contenteditable>
    试试这个,以上代码放到浏览器地址栏
    lizhenda
    lizhenda
    Jul 11, 2023
    5
    这还要用 PHP ???
    redsun368573607
    redsun368573607
    Jul 11, 2023❤️1
    6
    你这个 submit 还被显示了就离谱
    ellermister
    ellermister
    Jul 11, 2023 via Android
    7
    这个 submit 离谱,有趣!

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

    本意就是有一个在线记事本,记一些常用的网址密码。。随手拿来用,现成的各种 PASTEBIN 都太大太臃肿。
    我也不太满意,请大家修改补充完善。。。
    lewiet
    lewiet
    OP
    Jul 12, 2023
    12
    还有就是可以 0 成本部署在一个只有自己知道的 URL ,连密码都省了
    redsun368573607
    redsun368573607
    Jul 16, 2023
    13
    @zhishixiang 插了一个 submit 而已,js 应该插不了
    xiaokeplus
    xiaokeplus
    Jul 25, 2023
    14
    这网站没有 htmlspecialchars...
    xiaokeplus
    xiaokeplus
    Jul 25, 2023
    15
    <script>alert(1);</script>
    @xiaokeplus
    g001
    g001
    Sep 27, 2023
    16
    <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>
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4341 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 04:02 · PVG 12:02 · LAX 20:02 · JFK 23:02
    ♥ Do have faith in what you're doing.