登录按钮不起作用


Login button not working

我是Web开发的新手,想要制作一个简单的登录表单,尽管不确定为什么我的登录按钮没有响应,用户需要输入他们的电子邮件和密码。 用户输入密码后,登录按钮不起作用。

 <?php
 session_start();

    if(isset($_POST['submit'])) {
        include_once("php/config/database.php"); 
        $Email = strip_tags($_POST['Email']);
        $dbPassword = strip_tags($_POST['Password']);
        $Email = stripslashes($Email);
        $dbPassword = stripslashes($dbPassword);
        $Email = mysqli_real_escape_string($conn, $Email);
        $dbPassword = mysqli_real_escape_string($conn, $dbPassword);
        $dbPassword = md5($dbPassword);
        $sql = ("SELECT * FROM 'Users' WHERE Email='$Email' LIMIT 1");
        $query = mysqli_query($conn, $sql);
        $row = mysqli_fetch_array($query);
        $UserID = $row['UserID'];
        $dbpass_Password = $row['Password'];
        if($dbPassword == $dbpass_Password) {
            $_SESSION['Email'] = $Email;
            $_SESSION['UserID'] = $UserID;
            header("Location: account.php");
        } 
        else 
        {
            echo "You didn't enter the correct details!";
        }
    } 

?>

        <html >
          <head>
            <meta charset="UTF-8">
            <title>background</title>


                <link rel="stylesheet" href="css/style.css">
         <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
             <script src="js/index.js"></script>


          </head>
          <body>

            <div class="container demo-1">


              <div class="content">
                <div id="large-header" class="large-header">
              <form  action="index.php" method="POST>  
                  <div class="box">

              <h1 id="logintoregister">Login</h1>

          <div class="group show">      
              <input class="inputMaterial" type="text" name="FirstName" >
              <span class="highlight"></span>
              <span class="bar"></span>
              <label>First Name</label>
              </div>
            <div class="group show">      
              <input class="inputMaterial" type="text" name="Surname" >
              <span class="highlight"></span>
              <span class="bar"></span>
              <label>Surname</label>
              </div>

             <div class="group ">      
              <input class="inputMaterial" type="email" name="Email" >
              <span class="highlight"></span>
              <span class="bar"></span>
              <label>Email</label>
              </div>
            <div class="group">      
              <input class="inputMaterial" type="password" id="password" name="Password" >
              <span class="highlight"></span>
              <span class="bar"></span>
              <label>Password</label>
              </div>
            <div class="group show">      
              <input class="inputMaterial" type="password"  id="confirm_password" >
              <span class="highlight"></span>
              <span class="bar"></span>
              <label>Confirm Password</label>
              </div>

        <button id="buttonlogintoregister"  type = "submit" name="submit">Login</button>
          <p id="plogintoregister">By registering, You accept all terms and conditons </p>
          <p id="textchange" onclick="register()"> Sign Up</p>

                 </form> 


              <!-- Related demos -->


         <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
             <script src="js/index.js"></script>

        </body>
        </html>

你的 html 坏了:

      <form  action="index.php" method="POST" />  
                                              ^---

您自行关闭表单标签,因此页面上的每个输入字段都在表单之外

另外请注意,您还有其他逻辑错误:

        if($Password == $dbpass_Password) {
              ^----

$password是用户PW的sql转义版本。如果该密码自然包含 SQL 元字符,则该密码将不会与数据库中的内容相等。这些转义在数据库插入过程中被剥离,您最终会执行类似

 "Miles O''Brien" == "Miles O'Brien"

并返回错误的不匹配。