Jump to content

Notice: Undefined index


mcrackin

Recommended Posts

I'm using this tutorial to make a login system for my website.

 

I'm running the page on my localhost but I'm getting errors all over demo.php that say Notice: Undefined index: msg at .....

 

 

What does Undefined index mean and how do I fix this?

 

Matt

Edited by mcrackin
Link to comment
Share on other sites

You are getting that error because your error reporting is set to a high threshold, which it should be for developing purposes. But, they would be lower in production.

 

When you try to reference a variable that doesn't exist - it is an undefined variable or, in this case, you may be referencing the index of an array where the array exists but the index does not. For example:

if($_SESSION['msg']['reg-err'])

 

If that session value has not been set that if() statement would generate that error. TI don't know what the intent was for that condition. If the intent was to check if the variable was set, then you should use

if(isset($_SESSION['msg']['reg-err']))

 

But if the intent was to check if the value was not false, then you should first check if the variable is set, then check if it is not false.

if(isset($_SESSION['msg']['reg-err']) and $_SESSION['msg']['reg-err'] != false)

 

In a production environment set to a lower error reporting threshold, that code would probably work just fine, but it is poor coding practice. But, looking at that tutorial, I would suggest finding a better one.

Link to comment
Share on other sites

If you post what's going on then we'll be glad to help.

 

Have you checked your mail logs for errors? If you are on linux it should be in /var/log/messages or /var/log/maillog. Not sure about windows though.

 

If it's a PHP error go ahead and post that. If you think the script is being executed but mail is just not being sent without an error make sure the mail function is indeed being executed and check the logs for errors.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.