PHP表单未在同一页面中打开


PHP form not opening in the same page

我有一个按钮,可以在同一页上打开一个表单。

按钮被包裹在一个链接中,如下所示:

<a href="index.php?entry=true">
  <button type="submit">Enter now!</button>
</a>

表单就在这个链接下面,所有内容都在同一页上。我的问题是它在IE7和IE8中不起作用,还有想法?其他地方都很好!

<button>应该是<form>的一部分,而不是<a>,因此您的有效标记将是

<form method="post" action="index.ph?entry=true">
<button type="submit">Enter now!</button>
</form>

编辑:好的,所以你们需要一个看起来像按钮的东西。样式<A>使用CSS(未测试,但你得到了图片):

a:link {
 border-style: solid;
 border-width : 1px 4px 4px 1px;
 text-decoration : none;
 padding : 4px;
 border-color : #69f #00f #00f #69f;
 }

您不应该将按钮包装在锚点元素中,这不是有效的标记(根据W3C)。

使用abutton;不是两者都在一起。

根据w3c,您"不能"在a标记中嵌套按钮。

如果你想在按下按钮后进行一些重定向,请这样做:

<button type="button" onclick="document.location.href='example.com'">Leave this Place!</button>

如果不设置该类型,则默认情况下会得到一个<button type="submit">