我遇到了这个问题,无法完成这个简单的脚本.基本上,我想从表单中获取帖子,将其分配给变量,然后将变量附加到预先存在的example.txt文件中.对于缺少示例,我深表歉意.出去吃饭后,我和我的小s子切换到了手机.谁能发表一个简单的例子,然后让我建立这个基础?预先感谢
I'm having this problem where I can't manage to accomplish this simple script. Basically, I want to take a post from a form, assign it to a variable, and then append the variable to a preexisting example.txt file. I apologize for the lack of examples, I switched to my phone after I went out to dinner with my inlaws. Could anyone post a simple example andd allow me to build off of that foundation? thanks in advance
推荐答案以下内容应为您奠定基础.
The following should give you a foundation to start.
<?php // Check to see if the form was submitted if(isset($_POST['action']) && $_POST['action'] == 'add'){ $file = 'example.txt'; // Open the file to get existing content $current = file_get_contents($file); // Append a new person to the file $current .= $_POST['test']; // Write the contents back to the file file_put_contents($file, $current); } ?> <form method="POST"> <!-- This becomes PHP variable $_POST['test'] --> <input type="text" name="test" /> <input type="hidden" name="action" value="add" /> <input type="submit" value="Add"/> </form>有关更多信息,请查看 us3.php/file_put_contents .
Check out us3.php/file_put_contents for more information.
更多推荐
PHP发布到变量,然后追加到TXT
发布评论