标签<a onclick="file.php"> and refresh page

时间:2019-02-19 09:07:37

标签: php forms

I have a login form; this is a part of my code:

<form method="post" action="login.php" >
     <label>Username</label>
     <input type="text" name="username"/>
       <br>
     <label>Password</label>
     <input type="password" name="password"/>
       <br>
     <div class="log"><a class="btn btn_red">Login</a></div>
</form>

What I expect is that this form redirect me to the "login.php" file, but it doesn't work. Where am I going wrong?

Thank u all.

2 个答案:

答案 0 :(得分:4)

您有一个锚点(没有href属性)并且没有按钮。

您需要一个提交按钮

 <div class="log"><button class="btn btn_red">Login</button></div>

答案 1 :(得分:-1)

尝试一下

<form method="post" action="login.php" id="form1">
        <label>Username</label>
        <input type="text" name="username"/>
          <br>
        <label>Password</label>
        <input type="password" name="password"/>
          <br>
        <div class="log"><button type="submit" class="btn btn_red" form="form1" value="Submit">Login</button></div>
</form>