我无法获取从我的 php 文件中的 html 表单发送的 $_POST['name'] 值。我见过很多类似的问题,但没有任何帮助。我有很多包含,所以我认为这是一个范围问题,但我无法弄清楚。
索引.php
print_r($_POST); //Returns nothing, tried other ways too
//lot's of variables being defined
include 'sql_data_handlers.php';
//instantiating some things
sql_data_handlers.php
//some functions retrieving data from sql db and finally:
include($DOCUMENT_ROOT . "page.html");
page.html
//html stuff
<?php
//Some conditions
include($DOCUMENT_ROOT . "comment_form.html");
?>
comment_form.html
<form action="index.php" name="comment_form" id="comment_form" method="post">
<input type="text" name="name" value="Anonymous" required><br>
//lot's of inputs
<input type="submit">
</form>
我曾经有,action="send_comment.php"
但我意识到它可以变成一个函数,所以我 ctrl+c 并适应send_comments.php
了一个函数sql_data_handlers.php
。问题是,现在我无法获取要在函数 on (包含在 中)中使用的$_POST
值。index.php
sql_data_handlers.php
index.php
如果可能的话,我会使用action="my_php_function_from_data_handlers.php($args)"
,但我想不是。顺便说一句,我已经试过了action=""
。这可能看起来很混乱,但这样我只需要一个 .html 来进行站点布局,页面在 sql 上,而 .php 文件完成所有工作。
所有文件的完整来源(相当大,仍在处理中): http: //pastebin.com/2nRuCpNx