[英]Form submit not working with twitter bootstrap (PHP $_POST)
I just started using twitter bootstrap, and I got stuck trying to get my form submit button to submit (PHP $_POST). 我刚开始使用twitter bootstrap,我试图让我的表单提交按钮提交(PHP $ _POST)。 Does anyone know why its not working?
有谁知道它为什么不起作用?
No clue really.. 真的没有头绪..
I've been doing this previously and its been working until bootstrap: 我以前一直这样做,它一直在工作直到bootstrap:
<?php
if (isset($_POST["login"]) && $_POST["login"]=="login") {
echo "login here";
}
?>
<form action="http://mysite.com" method="post">
<input type="hidden" id="login" name="login" value="login" />
<button class="btn success" type="submit">Login</button>
</form>
The page seems to load but the PHP does not. 该页面似乎加载但PHP没有。 Is the POST information being blocked?
POST信息是否被阻止?
我的表单输入元素没有id或名称(我的示例中没有包含它们) 。
Not an HTML expert, but I've always used <input type="submit" />
and not <button type="submit" />
, not sure that button
is a functional form element. 不是HTML专家,但我总是使用
<input type="submit" />
而不是<button type="submit" />
,不确定该button
是否为函数表单元素。
Also, your button
element is closed twice - first with />
in the opening tag, and then again with a closing tag for no reason. 此外,您的
button
元素关闭两次 - 首先在开始标记中使用/>
,然后再次使用结束标记无缘无故。
I had this same issue as well, turns out I was missing the name="submit". 我也有同样的问题,原来我错过了名字=“提交”。 Gotta have that so the $_POST has a key in the assoc array!
得到这个,所以$ _POST在assoc数组中有一个键!
Maybe you are wrong with the action="http://mysite.com"
? 也许你对
action="http://mysite.com"
错了? That attribute is for specifing the form data receiver, so in your case I think it's the page itself. 该属性用于指定表单数据接收器,因此在您的情况下,我认为它是页面本身。 So, if your page is named
mypage.php
, use action="mypage.php"
. 因此,如果您的页面名为
mypage.php
,请使用action="mypage.php"
。
it is adviseable that every element has a name thus (name="elementName") this makes it easy to reference them in your php scipt; 建议每个元素都有一个名称(name =“elementName”),这样可以很容易地在你的php scipt中引用它们; also ensure that a form action and method are set.
还要确保设置表单操作和方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.