我想在服务器上保存一个文本文件,所以我使用带有一些标志的file_put_contents
。我还必须从包含一些人名的<input type="text" name="loaded">
字段中导入一个值。
<input type="text" name="loaded">
//other html code
<form method="post" action="scriptf.php">
<input type="submit" value="Go!" />
</form>
此脚本只保存在foldera/file.txt上的"Lucas Smith(lsmith334)+",但缺少ex
(包含该输入中的文本)。
<?php
$file = 'foldera/file.txt';
$ex = $_POST['loaded'];
$person = "Lucas Smith (lsmith334) + ".$ex;
file_put_contents($file, $person, FILE_APPEND | LOCK_EX);
?>
我做错了什么?
您的输入不在表单中
<form method="post" action="scriptf.php">
<input type="text" name="loaded">
<input type="submit" value="Go!" />
</form>
如果有效,所有输入都需要在表单标签内
嵌套表单是个坏主意,应该完全避免,我想不出一个好的理由来嵌套它们
它实际上也违反了标准你能嵌套html表单吗?
多个表单是没有问题的,嵌套表单是