Html 表单内的按钮不应提交表单
在我的表单标签中,我有两个名为SIGNIN和SIGNUP的按钮,如果按下SIGNIN按钮,则表单应提交。若注册按钮按下,它应该重定向到下面锚标签中给出的url,但它总是提交表单。请帮帮我Html 表单内的按钮不应提交表单,html,forms,Html,Forms,在我的表单标签中,我有两个名为SIGNIN和SIGNUP的按钮,如果按下SIGNIN按钮,则表单应提交。若注册按钮按下,它应该重定向到下面锚标签中给出的url,但它总是提交表单。请帮帮我 <form action="controllers/user/vauth.php" method="post" role="form" class="userLogin" style="padding:20px;"> <div class='alert alert-danger' id
<form action="controllers/user/vauth.php" method="post" role="form" class="userLogin" style="padding:20px;">
<div class='alert alert-danger' id='errorLabel' style="display:none;"></div>
<?php
if(isset($_SESSION['error'])) {
echo "<div class='alert alert-danger' id='errorLabel'>";
foreach($_SESSION['error'] as $error) echo "<p><b>".$error."</b></p>";
echo "</div>";
unset($_SESSION['error']);
}
if(isset($_SESSION['message'])) {
echo "<div class='alert alert-success'>".$_SESSION['message']."</div>";
unset($_SESSION['message']);
}
?>
<div class="form-group">
<label for="email">Email</label>
<input type="text" name="vemail" id="vemail" class="form-control" placeholder="Enter Email" value="<?php if(isset($_SESSION['values'])) echo $_SESSION['values']['email']; ?>">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" name="vpassword" id="vpassword" class="form-control" placeholder="Enter Password">
</div>
<div class="form-group">
<a href="user/vfpass.php">Forgot Password ?</a>
</div>
<button type="submit" class="btn btn-default" name="vsubmit">LOG IN</button><a href="../signup"><button class="btn btn-success" name="signup" style="float:right;">SIGN UP</button></a>
</form>
将type=“button”
添加到注册按钮中将按钮类型更改为按钮
,而不是submit
。为什么不将第二个按钮(注册)移到标签外?@Lal你看了代码了吗?他没有在第二个按钮中使用submit..BWT看起来您正在使用引导。你知道吗,如果你添加role=button(如果我记得的话),你只能使用tag作为abutton。查看引导css页面了解更多信息。(然后可以移除内部按钮标签)