dplece1882 2019-05-11 21:17
浏览 138
已采纳

无法登录(MySQL,PHP)

So I need to make a whole login system for my graduation project. I already made a database on mysql which works perfectly. The register part of the login works but if I try to login with the account I just made, it doesnt work. Most of the time I'm getting the error 'Password/e-mail is wrong' while its correct?

Thanks in advance!

   <?php
    include("config.php");
    session_start();

    $email =$_POST['email'];
   $password =$_POST['password'];
   if(empty($email))
    {

        exit();

    }else {
      $stmt =mysqli_stmt_init($db);
      $sql = "SELECT * FROM users WHERE email=?;";

      if(!mysqli_stmt_prepare($stmt, $sql))
      {

        echo"No data";
      }else
      {
        mysqli_stmt_bind_param($stmt, "s", $email);
        mysqli_stmt_execute($stmt);
        $result = mysqli_stmt_get_result($stmt);
        if($row = mysqli_fetch_assoc($result))
        {
             $combicheck = password_verify($password,$row['password']);
            if($combicheck == false)
            {

                echo"Password / email is wrong";
                  exit();
            }else if($combicheck == true){
            session_start();
            $_SESSION['password'] = $row['password'];
            header('Location: index.html');
            echo"Logged in";
            }

        }else
        {
          echo"Failed";
        }
      }
    }
  • 写回答

1条回答 默认 最新

  • drz73366 2019-05-11 23:11
    关注

    <form action="login.php" method="POST">
      <input type="text" name="" /> <br />
      <input type="password" name="" /> <br />
      <input type="submit" name="submit" value="login" />
    </form>

    Change display_errors=Off to display_errors=On in your php.ini file

    if method="POST" then $_POST in php

    if method="GET" then $_GET in php

    If you are not sure is GET or POST method

    debug using

    In your login.php

    echo "This is Post method";
    var_dump($_POST);
    echo "This is Get method";
    var_dump($_GET);
    
    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)