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

    评论

报告相同问题?

悬赏问题

  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思