登录.php的问题 [英] Problems with the login .php

查看:95
本文介绍了登录.php的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个登录表单,但总是收到警告错误。



警告:mysqli_fetch_array()要求参数1为mysqli_result,在C:中给出布尔值13行上的\\ xampp \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 16号线上的\\ xampp \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ $ b

I create a login form, but always receive a warning error.

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\login\login.php on line 13

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\login\login.php on line 16

What I have tried:

<?php
   include("config.php");
   session_start();
   
   if($_SERVER["REQUEST_METHOD"] == "POST") {
      // username and password sent from form 
      
      $myusername = mysqli_real_escape_string($db,$_POST['username']);
      $mypassword = mysqli_real_escape_string($db,$_POST['password']); 
      
      $sql = "SELECT id FROM username WHERE id = '$myusername' and passcode = '$mypassword'";
      $result = mysqli_query($db,$sql);
      $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
      $active = $row['active'];
      
      $count = mysqli_num_rows($result);
      
      // If result matched $myusername and $mypassword, table row must be 1 row
    
      if($count == 1) {
         session_register("myusername");
         $_SESSION['login_user'] = $myusername;
         
         header("location: table.php");
      }else {
         $error = "Your Login Name or Password is invalid";
      }
   }
?>
<html>
   
   <head>
<title>Recorder Penguin</title>
<script defer src="https://use.fontawesome.com/releases/v5.0.9/js/all.js" integrity="sha384-8iPTk2s/jMVj81dnzb/iFR2sdA7u06vHJyyLlAd4snFpCl/SnyUjRrbdJsw1pGIl" crossorigin="anonymous"></script>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>

<body>
<style>
html { 
  background: url(icy_cold_blue_by_ivanthelonewolf-d3kq23z.jpg) no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}
body{
  background: none;
}
.jumbotron{
  background-color:rgba(0, 204, 204,0.3);
}
</style>
  
      <nav class="navbar navbar-light bg-faded">
<div class="container">
  <div class="navbar-header">
   <a class="nav navbar-nav" >
  <li><img src="LOGO4.png" width="60" height="60" class="d-inline-block align-top" alt=""></li>
   <li><h2 class="nav-brand-nav">RECORD PENGUIN</h2></li>
   </div>
   <ul class="nav navbar-right navbar-right" style="margin-top:30px ">
   <li><ul><a href="register.php"> Register</a></li><ul>
   </ul>
   </div>
  
</nav>

<div class="container">

<div class="jumbotron">
               
               <form action = "" method = "post">
                  <label>UserName  :</label><input type = "text" name = "username" class = "box"/><br /><br />
                  <label>Password  :</label><input type = "password" name = "password" class = "box" /><br/><br />
                  <button type = "submit" class="btn btn-success btn-lg"id="submit"name="submit" value = " Submit "/>Login</button><br />
               </form>

               <div style = "font-size:14px; color:#cc0000; margin-top:10px"><?php echo $error; ?></div>
          
            </div>
        
         </div>
      
      </div>

   </body>
</html>

推荐答案

_SERVER [REQUEST_METHOD] ==POST){
//从表单发送的用户名和密码
_SERVER["REQUEST_METHOD"] == "POST") { // username and password sent from form


myusername = mysqli_real_escape_string(
myusername = mysqli_real_escape_string(


db,


这篇关于登录.php的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆