dongxian8858 2014-03-14 16:20
浏览 141
已采纳

注意:未定义的索引:消息错误

I am trying to learn php coding and it's now hitting a snag as I keep getting an error:

Error: Notice: Undefined index: msg in C:\xampp\htdocs\kubebook\index.php on line 12

Source Code:

if ($_GET['msg'] == 1)  {

echo "You have successfully registered.";

}
  • 写回答

1条回答 默认 最新

  • doujiu4643 2014-03-14 16:24
    关注

    You get that message when you attempt to reference an index or variable that isn't defined. In this case, you aren't passing a yourscript.php?msg=123 param to the script, so $_GET['msg'] doesn't exist. First check if it is set before looking at value

    if (isset($_GET['msg']) && $_GET['msg'] == 1)  {
    
    echo "You have successfully registered.";
    
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?