【问题标题】:How do you dump data from a html form into .json using PHP(or any other back-end language)?如何使用 PHP(或任何其他后端语言)将数据从 html 表单转储到 .json?
【发布时间】:2019-10-25 01:49:43
【问题描述】:

所以,我正在开发一个表格,该表格将由一个程序检查以使用数据执行。如何将数据转储到带有 html 表单或任何其他语言的 .json 文件中?

为了项目起见,我将给出一段 html 表单以帮助理解。

<form action="/folder/data.php" method="post">
  <div>
    <label for="firstname">First Name:</label>
    <input type="text" id="firstname" name="firstname">
  </div>
  <div class="button">
    <button type="submit">Sumbit!</button>
   </div>
</form>

【问题讨论】:

    标签: html json forms


    【解决方案1】:

    根据我的(有限)经验,链接到 PHP 文件以处理提交的表单字段的“操作”,如下所示:Insert input data from HTML form into JSON object and then store it in MYSQL)。

    基本上,您将使用“json_encode”(对于 PHP)或类似的东西将输入字段转换为 JSON 对象。

    你可能想看看这个问题:How to send a JSON object using html form data

    【讨论】:

      猜你喜欢
      • 2018-01-18
      • 2019-10-18
      • 2016-02-21
      • 2012-03-31
      • 2012-01-19
      • 2013-11-07
      • 2016-09-05
      • 2020-01-05
      • 2014-11-20
      相关资源
      最近更新 更多