PHP注意:未定义索引:选择消息
我总是遇到这样的错误:PHP注意:未定义索引:选择消息,php,indexing,undefined,Php,Indexing,Undefined,我总是遇到这样的错误: 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 `$
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">';
}
$message=$\u POST['selecting-message'];
$update=mysqli_query($connect,“update`$table`SET enabled='$enabled',alert='$alert',message='$message',其中id=14”);
回声';
}
通知告诉您,POST数组不包含带有键选择消息的元素。这可能是上一页表单上的一个空字段,也可能是打字错误或其他原因导致它不存在
只需检查一个值,而不是假设它存在:
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">';
}
if(设置($\u POST['selecting-message'])){
$message=$\u POST['selecting-message'];
$update=mysqli_query($connect,“update`$table`SET enabled='$enabled',alert='$alert',message='$message',其中id=14”);
回声';
}
我发现“意外的文件结尾”错误通常是由代码中某个不平衡的大括号“{}”引起的。检查一下,看看是否有一个“{”没有相应的“}”
kev.您可能应该阅读一些关于SQL注入的内容。将POST值直接传递到查询中而不进行清理将导致网站被入侵。这是一个简单的PHP web shell,如上所述,允许在web服务器上执行代码。最好摆脱它并强化应用程序将生成Post数据的上一页的代码张贴出来。该通知告诉您的是,POST数组中未设置选择消息的。未定义的索引意味着它不存在。