php HTML 表单提交给自己
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12009910/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTML Form Submit To Self
提问by ackerchez
Can someone tell me why on earth this is not submitting to self?
有人能告诉我为什么这不是顺服自我吗?
I have the following setup:
我有以下设置:
<?php
print_r($_POST);
?>
<form name="bizLoginForm" method="post" action"" >
<table id="loginTable">
<tr><td>Username:</td><td><input type="text" id="loginUsername" /></td></tr>
<tr><td>Password:</td><td><input type="password" id="loginPassword" /></td></tr>
</table>
<input type="Submit" value="Login" />
</form>
and every time I click on the submit button i see nothing inside the POST array. What simple thing have I totally overlooked?
每次我点击提交按钮时,我都看不到 POST 数组中的任何内容。我完全忽略了什么简单的事情?
Thanks!
谢谢!
回答by Richard M
Aside from the fact the equals is missing from your actionattribute in your form element.
除了action您的表单元素中的属性中缺少 equals 之外。
Your inputs need name attributes:
您的输入需要名称属性:
<tr>
<td>Username:</td>
<td><input id="loginUsername" name="loginUsername" type="text" /></td>
</tr>
回答by sjobe
<form name="bizLoginForm" method="post" action"" >
should be
应该
<form name="bizLoginForm" method="post" action="" >
Missing = sign.
缺少 = 符号。
You're also missing the name attribute inside your input tags, so change
您还缺少输入标签中的 name 属性,因此请更改
<input type="text" id="loginUsername" />
and
和
<input type="password" id="loginPassword" />
to
到
<input type="text" id="loginUsername" name="loginUsername" />
and
和
<input type="password" id="loginPassword" name="loginPassword" />
回答by mintobit
- You should add equalssign between actionand ""
- Also specify nameattribute for each input field.
- 您应该在操作和“”之间添加等号
- 还要为每个输入字段指定name属性。
<?php
print_r($_POST);
?>
<form name="bizLoginForm" method="post" action="" >
<table id="loginTable">
<tr><td>Username:</td><td><input type="text" name="login" id="loginUsername" /></td></tr>
<tr><td>Password:</td><td><input type="password" name="password" id="loginPassword" /></td></tr>
</table>
<input type="Submit" value="Login" /></form>
回答by Pradeep
Try this
尝试这个
<?php
if(isset($_POST['submit_button']))
print_r($_POST);
?>
<form name="bizLoginForm" method="post" action"<?php echo $_SERVER['PHP_SELF']?>" >
<table id="loginTable">
<tr><td>Username:</td><td><input type="text" id="loginUsername" /></td></tr>
<tr><td>Password:</td><td><input type="password" id="loginPassword" /></td></tr>
</table>
<input type="Submit" name="submit_button" value="Login" />
</form>
Save the file with .php extension
使用 .php 扩展名保存文件
回答by alsahin
try this
尝试这个
<?php
if(isset($_GET["submitted"])){
print_r($_POST["values"]);
} else {
?>
<form name="bizLoginForm" method="post" action="?submitted" >
<table id="loginTable">
<tr><td>Username:</td><td><input type="text" name="values[]" id="loginUsername" /></td></tr>
<tr><td>Password:</td><td><input type="password" name="values[]" id="loginPassword" /></td></tr>
</table>
<input type="Submit" value="Login" />
</form>
<?php
}
?>

