duancan5327 2018-05-08 03:14
浏览 99
已采纳

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";
       }
        }       
      ?>    
  • 写回答

1条回答 默认 最新

  • dpzjl68484 2018-05-08 03:26
    关注

    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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line