user3421962
user3421962

Reputation: 3

Notice: Undefined index: message error

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

}

Upvotes: 0

Views: 4227

Answers (1)

CrayonViolent
CrayonViolent

Reputation: 32532

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

}

Upvotes: 2

Related Questions