dongxian8858
2014-03-15 00:20
浏览 123
已采纳

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

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.";

}

图片转代码服务由CSDN问答提供 功能建议

我正在尝试学习PHP编码,现在我遇到了一个错误:

错误:注意:未定义的索引:第12行的C:\ xampp \ htdocs \ kubebook \ index.php中的msg

源代码:

  if($ _GET ['msg'] == 1){
 
echo“您已成功注册。”; 
 
  } 
   
 
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doujiu4643 2014-03-15 00: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.";
    
    }
    
    已采纳该答案
    打赏 评论

相关推荐 更多相似问题