本文介绍了未定义的索引PHP错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用000webhost创建一个登录页面,并且这个错误不断出现,我知道这些问题有大量的问题,但我还是无法修复它



这是错误



注意:未定义的索引:在/storage/ssd1/326/5052326/public_html/login.php上有效14



警告:无法修改标题信息 - 已经发送的标题(输出从/storage/ssd1/326/5052326/public_html/login.php:14开始)第23行/storage/ssd1/326/5052326/public_html/login.php



这是代码



I've been trying to make a login page with 000webhost, and this error keeps popping up, and i know there are tons of these king of questions everywhere but i still cant fix it

this is the error

Notice: Undefined index: active in /storage/ssd1/326/5052326/public_html/login.php on line 14

Warning: Cannot modify header information - headers already sent by (output started at /storage/ssd1/326/5052326/public_html/login.php:14) in /storage/ssd1/326/5052326/public_html/login.php on line 23

and this is the code

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

      // username and password sent from form 
    if($_SERVER["REQUEST_METHOD"] == "POST") {

      $myusername = mysqli_real_escape_string($db,$_POST['username']);
      $mypassword = mysqli_real_escape_string($db,$_POST['password']);

      $sql = "SELECT * FROM admin WHERE username = '$myusername' and password = '$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['login_user'] = $myusername;

         header("location: welcome.php");
      }else {
         $error = "Your Login Name or Password is invalid";
      }
    }
?>





我尝试了什么:



即使我的老师也无法修复它



What I have tried:

even my teacher couldnt fix it

推荐答案




这篇关于未定义的索引PHP错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 18:46