doulan1866 2018-11-16 09:37
浏览 55

网页刷新到不正确的表单提交

If I enter an Incorrect email address or password my site refreshes to the top of the page and I see this error

Incorrect email and Pass 

I have to scroll back down to where my form is to see a detailed error.

I want to prevent my page going to the top.

I have searched for a solution on here but can't find anything.

HTML Code:

<body>

    <form method="post" style="margin-right:450px;">
        <table align="center" cellspacing="3px;">

            <tr>
                <td>
                    <input style="border:1px #666 solid; border-radius: 4px; width: 180px; padding: 12px 20px; font-size:18px;" type="email" name="mail" required placeholder="Your Email">
                </td>

                <td>
                    <input style="border:1px #666 solid; border-radius: 4px; width: 180px; padding: 12px 20px; font-size:18px;" type="password" name="pass" required placeholder="Your Password">
                </td>
            </tr>

        </table>

        <br><br>

        <button class="button button3" type="submit" name="log" style="color:#FFF; text-align:center; margin-left:70px;">Log In</button></td>

    </form>
</body>

PHP Code:

<?php

    $con=mysqli_connect("localhost","root","","form_data");

    if(isset($_POST['log']))

    {
        $_SESSION['mail'] = $_POST['mail'];

        $email = $_POST['mail'];

        $Password = $_POST['pass'];

        $query = mysqli_query($con,"select * from registration where (User_name = '$email' or Email= '$email') and Password = '$Password' ");

        $check = mysqli_num_rows($query);   

        if($check == 1)
        {

            echo "<h1> User Login <h1>";

            header("location:exam.php");
        }
        else
        {
            echo "<div class='error'> ";
            echo "!! Invalid Username Or Password !!";
            echo "</div>";

        }
    }

?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在炒股软件中,爬到我想看的日k线
    • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
    • ¥15 seatunnel 怎么配置Elasticsearch
    • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
    • ¥15 (标签-MATLAB|关键词-多址)
    • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
    • ¥500 52810做蓝牙接受端
    • ¥15 基于PLC的三轴机械手程序
    • ¥15 多址通信方式的抗噪声性能和系统容量对比
    • ¥15 winform的chart曲线生成时有凸起