douyi2664 2014-12-31 16:39
浏览 10

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

This question already has an answer here:

Guys i am a complete noob in PHP, and so i need help with my question. Here is my code:

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

I would like the name field to be saved to a text file.

</div>
  • 写回答

1条回答 默认 最新

  • dqjmq28248 2014-12-31 16:44
    关注

    You should specify the input name first.

        <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>
    

    Send the post data to the php page. And paste this code there

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

    Hope this helps you

    评论

报告相同问题?