Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用PHP或其他工具修改HTML文档_Php_Html - Fatal编程技术网

使用PHP或其他工具修改HTML文档

使用PHP或其他工具修改HTML文档,php,html,Php,Html,假设我有这个文件: <html> <body> <p id="change"></p> </body> </html> 然后我有另一份文件 <html> <body> <input type="text" name="message"> <input type="submit" value="Send"> <

假设我有这个文件:

<html>
    <body>
    <p id="change"></p>

    </body>
</html>

然后我有另一份文件

<html>
    <body>
    <input type="text" name="message">
    <input type="submit" value="Send">
    </body>
</html>


我想用您在第二个文档中输入的文本更改第一个文档的
。如何做到这一点?

第一个文档:

<html>
    <body>
    <p id="change"><?php echo(htmlentities($_POST['message'])); ?></p>

    </body>
</html>
<html>
    <body>
    <form method="post" action="first_document.php">
       <input type="text" name="message">
       <input type="submit" value="Send">
    </form>
    </body>
</html>

第二份文件:

<html>
    <body>
    <p id="change"><?php echo(htmlentities($_POST['message'])); ?></p>

    </body>
</html>
<html>
    <body>
    <form method="post" action="first_document.php">
       <input type="text" name="message">
       <input type="submit" value="Send">
    </form>
    </body>
</html>

更改“first_document.php”以匹配第一个文档的实际文件名

工作原理:

<html>
    <body>
    <p id="change"><?php echo(htmlentities($_POST['message'])); ?></p>

    </body>
</html>
<html>
    <body>
    <form method="post" action="first_document.php">
       <input type="text" name="message">
       <input type="submit" value="Send">
    </form>
    </body>
</html>

第二个文档设置一个html表单,其内容被发布到第一个文档(通过HTTP POST)。然后,第一个文档从post数据中获取“message”参数,通过htmlentities对其进行清理以防止跨站点脚本攻击,并将其输出到页面上。

但是如果我希望第一个文档保持这种状态,我应该使用mySql吗?您必须以某种方式修改第一个文档,因为目前它不接受任何输入。即使您使用MySql,您也必须修改第一个文档。我的意思是,例如,对于注释部分,我必须将注释上载到MySql,然后获取它并将其发布到
?在那之后,评论会永远留在那里吗?它通常不是这样工作的。通常,每次用户请求网页时,都会创建网页。这意味着,如果您使用的是数据库,则每次有人请求该页面时都会查询该数据库,并且数据库返回的信息每次都会回显到该页面上。因此,每当用户在“注释”部分中获得注释时,该页面都会从数据库中获取注释并显示它?酷,谢谢你的回答!您输入的文本的更改是什么意思?您的意思是当您在文档2中输入文本时,该文本应该插入到文档1中的p#id之间吗?是的,并保持这样,但我知道我必须使用mySQL:/