[英]Form data not POSTing to another page
I am struggling with a problem I have never had before. 我正在努力解决以前从未遇到过的问题。 I have a form on a page that submits its data via POST to another page, but the data is not arriving at the other page. 我在页面上有一个表单,通过POST将数据提交到另一个页面,但数据没有到达另一个页面。 If I make action=""
and then var_dump()
at the top of the page with the form, the POST data prints out fine, BUT if I make action="http://localhost/dir/"
and put var_dump()
at the top of that page, then array empty
prints out. 如果我使用表单在页面顶部创建action=""
然后var_dump()
,则POST数据打印出来就好了,但是如果我执行action="http://localhost/dir/"
并放入var_dump()
在该页面的顶部,然后打印出array empty
。 What on earth might be causing this behavior? 究竟是什么导致了这种行为? How do I debug this? 我该如何调试? I'm lost. 我迷路了。
Form: 形成:
<form id="form" method="post" action="http://localhost/dir">
<input type="hidden" name="id" value="19">
<select style="width: 60px;" name="number">
<option value="1">1</option><option value="2">2</option><option value="4">4</option>
</select>
<input type="submit" class="input_submit" value="Submit" id="submitButton">
</form>
Code at top of index.php file: index.php文件顶部的代码:
var_dump($_POST);die();
To post data to a page that is on a different directory, use a relative path. 要将数据发布到不同目录中的页面,请使用相对路径。
For example, consider this. 例如,考虑一下。 DirSub1 and DirSub2 are in the same level and they're both within DirTop. DirSub1和DirSub2处于同一级别,它们都在DirTop中。
Now, if your form is in the directory DirSub1 and you need to post it to x.php in DirSub2, you write the action property like this: 现在,如果您的表单位于DirSub1目录中,并且需要将其发布到DirSub2中的x.php,则可以像这样编写action属性:
action="../DirSub2/x.php" 行动= “../ DirSub2 / x.php”
Hope this solves your problem. 希望这能解决你的问题。
Try 尝试
<form id="form" method="post" action="../dir/index.php">
<input type="hidden" name="id" value="19">
<select style="width: 60px;" name="number">
<option value="1">1</option><option value="2">2</option><option value="4">4</option>
</select>
<input type="submit" class="input_submit" value="Submit" id="submitButton">
</form>
assuming 'dir' directory is out side the directory of the file which contains this form. 假设'dir'目录位于包含此表单的文件的目录旁边。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.