Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

button inside form should not submit form

Tags:

html

forms

in my form tag i have two buttons named SIGNIN and SIGNUP and form should be submit if SIGNIN button press. and if SIGNUP button press it should redirect to url given in anchor tag below but it always submitting the form. please help me.

<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>
like image 338
Divyesh Jesadiya Avatar asked Dec 14 '22 07:12

Divyesh Jesadiya


1 Answers

Add type="button" to your signup button

like image 116
SlyTech404 Avatar answered Dec 24 '22 03:12

SlyTech404