Reputation: 139
I just started using twitter bootstrap, and I got stuck trying to get my form submit button to submit (PHP $_POST). Does anyone know why its not working?
No clue really..
I've been doing this previously and its been working until 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. Is the POST information being blocked?
Upvotes: 5
Views: 27066
Reputation: 1
it is adviseable that every element has a name thus (name="elementName") this makes it easy to reference them in your php scipt; also ensure that a form action and method are set.
Upvotes: -2
Reputation: 1
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!
Upvotes: 0
Reputation: 139
My form input elements did not have an id or name (I didn't include them in my example).
Upvotes: 8
Reputation: 17010
Maybe you are wrong with the 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"
.
Upvotes: 0
Reputation: 797
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.
Also, your button
element is closed twice - first with />
in the opening tag, and then again with a closing tag for no reason.
Upvotes: 3