如何将文本字段中的文本输入保存到文件中?

时间:2014-12-31 16:39:20

标签: php

伙计们我是PHP中的一个完整的菜鸟,所以我需要帮助解决我的问题。这是我的代码:

<div class="form-group">
                  <input id="name" placeholder="test 123" value="" type="name" class="form-control">
                </div>

我希望将名称字段保存到文本文件中。

1 个答案:

答案 0 :(得分:0)

您应首先指定输入名称。

    <div class="form-group">
<form method="post" action="filename.php">
                      <input id="name" placeholder="test 123" value="" name="name" type="name" class="form-control">
    </form>
                    </div>

将发布数据发送到php页面。并将此代码粘贴到那里

<?php
$name = $_POST['name'];
file_put_contents("file_name.txt",$name); // Will put the text to file
?>

希望这有助于你

相关问题