mcrackin Posted July 25, 2013 Share Posted July 25, 2013 (edited) 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 July 25, 2013 by mcrackin Quote Link to comment https://forums.phpfreaks.com/topic/280521-notice-undefined-index/ Share on other sites More sharing options...
AbraCadaver Posted July 25, 2013 Share Posted July 25, 2013 You're trying to use an array with that index and it doesn't exist, maybe $_POST['msg'] or something similar? Quote Link to comment https://forums.phpfreaks.com/topic/280521-notice-undefined-index/#findComment-1442204 Share on other sites More sharing options...
Psycho Posted July 25, 2013 Share Posted July 25, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/280521-notice-undefined-index/#findComment-1442205 Share on other sites More sharing options...
mcrackin Posted July 25, 2013 Author Share Posted July 25, 2013 I've got rid of the errors and everything is working fine now except the mailing of my password part. Quote Link to comment https://forums.phpfreaks.com/topic/280521-notice-undefined-index/#findComment-1442208 Share on other sites More sharing options...
0xMatt Posted July 26, 2013 Share Posted July 26, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/280521-notice-undefined-index/#findComment-1442209 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.