php中的isset()函数无法正常工作,但也没有显示错误

php中的isset()函数无法正常工作,但也没有显示错误

问题描述:

I have created a login form to a clothing website. I have used the isset() function with if statement on the button click saying if the button is clicked... do this.... But, when I run on browser(I use xammp as my localhost), the page works fine but when i enter the credentials and press submit button, it does not redirect to the next page or does not even echo"Login Successful" or "Login failed. I used error reporting function in php to track the bugs but it did not show any either. Here is my code

IndexLogin.html

    <html lang="en">
    <head>
    <title>Login </title>
    </head>
    <body>

     <div class="limiter">
      <div class="container-login100">
        <div class="wrap-login100">
            <form class="login100-form validate-form">
                <form method="POST" form action="login.php">
                <span class="login100-form-title p-b-34">
                    SHAARANYA~<br>
                    Account Login
                </span>

                <div class="wrap-input100 rs1-wrap-input100 validate-input 
                m-b-20" data-validate="Type email">
                    <input id="email" class="input100" type="text" 
                     name="email" placeholder="email" >
                    <span class="focus-input100"></span>
                </div>
                <div class="wrap-input100 rs2-wrap-input100 validate-input 
                 m-b-20" data-validate="Type password">
                    <input class="input100" type="password" name="pass" 
                     placeholder="Password" >
                    <span class="focus-input100"></span>
                </div>

                <div class="container-login100-form-btn">
                    <button class="login100-form-btn"
                      button type="submit" name="submit">
                        Sign in
                    </button>
                </div>

                <div class="w-full text-center p-t-27 p-b-239">
                    <span class="txt1">
                        Forgot
                    </span>

                    <a href="#" class="txt2">
                        User name / password?
                    </a>
                    <br>
                    <br>
                    <p><font size="3">Not a Member Yet? Join us for FREE!
                    <br><br><a href="#"><b> SIGN UP </font></b> </a></p>

                </div>


            </form>
             </body>
             </html>

Login.php

      <?php

     error_reporting(E_ALL);
     ini_set('display_errors', '1');

     $servername = "localhost";
     $username = root;
      $password = "";
      $dbname="company";

       $conn = new mysqli($servername,$username,$password,$dbname);

       // Check connection
       if ($conn->connect_error) {
       die("Connection failed: " . $conn->connect_error);
       } 


       if(isset($_POST['submit'])){

       $email=$_POST['email'];
       $pass=$_POST['pass'];

       $sql = "SELECT * FROM login WHERE email = '".$email."' and pass = 
       '".$pass."'";

       $result = mysqli_query( $conn,$sql);
        if(mysql_num_rows($result)==1){
         echo "Login Successful";
       }

      else {
      echo "Failed To Login";
       }
        }       
      ?>    

I have cleaned your HTML script. Please try it now, hope this will work for you.

<html lang="en">
      <head>
        <title>Login</title>
      </head>
    <body>
       <div class="limiter">
          <div class="container-login100">
            <div class="wrap-login100">           
                    <form method="POST" form action="login.php">
                    <span class="login100-form-title p-b-34">
                        SHAARANYA~<br>
                        Account Login
                    </span>

                    <div class="wrap-input100 rs1-wrap-input100 validate-input 
                    m-b-20" data-validate="Type email">
                        <input id="email" class="input100" type="text" 
                         name="email" placeholder="email" >
                        <span class="focus-input100"></span>
                    </div>
                    <div class="wrap-input100 rs2-wrap-input100 validate-input 
                     m-b-20" data-validate="Type password">
                        <input class="input100" type="password" name="pass" 
                         placeholder="Password" >
                        <span class="focus-input100"></span>
                    </div>

                <div class="container-login100-form-btn">
                  <button class="login100-form-btn" type="submit" name="submit">
                            Sign in
                        </button>
                    </div>

                    <div class="w-full text-center p-t-27 p-b-239">
                        <span class="txt1">
                            Forgot
                        </span>

                        <a href="#" class="txt2">
                            User name / password?
                        </a>
                        <br>
                        <br>
                        <p><font size="3">Not a Member Yet? Join us for FREE!
                        <br><br><a href="#"><b> SIGN UP </font></b> </a></p>

                    </div>
                </form>
                 </body>
                 </html>