【问题标题】:PHP Notice: Undefined index: selecting-messagePHP 注意:未定义索引:选择消息
【发布时间】:2016-08-25 12:46:37
【问题描述】:

我总是收到这个错误:

PHP Notice: Undefined index: selecting-message in /content-protection.php on line 390" and I have tried for many hours to solve this.

我希望有人可以帮助我。

第 390 行代码:

$message = $_POST['selecting-message'];
$update  = mysqli_query($connect, "UPDATE `$table` SET enabled='$enabled', alert='$alert', message='$message' WHERE id=14");

echo '<meta http-equiv="refresh" content="0;url=content-protection">';
}

【问题讨论】:

  • 发布生成 POST 数据的上一页的代码。该通知告诉您的是,selecting-message 未在 POST 数组中设置。未定义的索引意味着它不存在。

标签: php indexing undefined


【解决方案1】:

您也许应该阅读一些有关 SQL 注入的内容。将 POST 值直接传递到查询中而不进行清理将导致网站被黑。

【讨论】:

    【解决方案2】:

    通知告诉您 POST 数组不包含键为 selecting-message 的元素。这可能是上一页表单中的空白字段、拼写错误或任何其他原因导致它不存在。

    只需检查一个值而不是假设它存在:

    if ( isset ( $_POST['selecting-message'] ) ) {
        $message = $_POST['selecting-message'];
        $update  = mysqli_query($connect, "UPDATE `$table` SET enabled='$enabled', alert='$alert', message='$message' WHERE id=14");
    
        echo '<meta http-equiv="refresh" content="0;url=content-protection">';
    }
    

    【讨论】:

      【解决方案3】:

      我发现“文件意外结束”错误通常是由代码中某处的不平衡大括号“{}”引起的。检查它,看看是否有一个'{'没有对应的'}'

      kev.

      【讨论】:

        【解决方案4】:

        它是一个简单的 PHP Web shell,如上所述,它允许在您的 Web 服务器上执行代码。最好摆脱它并强化您的应用程序

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-02-02
          • 2014-02-06
          • 2011-05-26
          • 2016-04-28
          • 2016-08-04
          • 1970-01-01
          相关资源
          最近更新 更多