【问题标题】:How to put form input into html file via php?如何通过php将表单输入放入html文件?
【发布时间】:2019-08-01 09:07:54
【问题描述】:

我有这个 html 文件:

<div>
    <div class="input">
        <img src="2017-01-10.jpg">
    </div>
    <div class="input">
        Some text here
    </div>
    <div class="input">
       January 10th 2017
    </div>
</div>

我想制作一个输入表单(在另一个页面中),在其上方添加一个这样的 div。

因此,用户可以在表单中填写图像、文本和日期,并在提交时添加到 html 文件中的代码上方,但需要新的输入。

最后的代码是这样的:

<div>
    <div class="input">
        <img src="2017-01-11.jpg">
    </div>
    <div class="input">
        Some text here
    </div>
    <div class="input">
       January 11th 2017
    </div>
</div>

<div>
    <div class="input">
        <img src="2017-01-10.jpg">
    </div>
    <div class="input">
        Some text here
    </div>
    <div class="input">
       January 10th 2017
    </div>
</div>

我会在表单的 php 文件中添加什么? php可以永久写入html文件吗?

【问题讨论】:

  • 您可以在数据库中插入表单数据并使用while循环在html页面中调用它
  • The manual 永远是第一个开始的地方
  • "我将在表单的 php 文件中放入什么?" — 您需要从介绍性 PHP 教程开始,而不是 Stackoverflow。 (嗯,你可以从the tag wiki开始,用它来寻找合适的教程)。
  • "php 可以永久写入 html 文件吗?" — 可能,但这是一个糟糕的主意。使用数据库。
  • 感谢您的回答!我会尝试学习一些php和Mysql

标签: html


【解决方案1】:

您需要处理对 SQL 数据库的用户输入。然后,用户输入将永久存储在 .html 文件中。但是您还没有完成,您还必须将.htaccess 文件添加到您的站点以将PHP 解析为HTML。

要了解如何将用户输入从 PHP 保存到 SQL 数据库,请观看此video。 要了解如何使用.htaccess,请观看此video

【讨论】:

    猜你喜欢
    • 2021-06-03
    • 2015-03-15
    • 2021-05-29
    • 2018-07-31
    • 1970-01-01
    • 2016-03-05
    • 1970-01-01
    • 1970-01-01
    • 2017-09-28
    相关资源
    最近更新 更多