Undefined index: login_user in D:\wamp\www\index.php on line

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shaunak1234
Forum Newbie
Posts: 13
Joined: Thu Nov 03, 2011 12:24 am

Undefined index: login_user in D:\wamp\www\index.php on line

Post by shaunak1234 »

I use login_user to validate login and display username!
I changed my server from ubuntu to windows,
Now I have this problem
Undefined index: login_user in D:\wamp\www\index.php
I know it is because my login_user is null at the index page!
Just how do i switch this warning off?
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Undefined index: login_user in D:\wamp\www\index.php on

Post by social_experiment »

“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
shaunak1234
Forum Newbie
Posts: 13
Joined: Thu Nov 03, 2011 12:24 am

Re: Undefined index: login_user in D:\wamp\www\index.php on

Post by shaunak1234 »

Actually I fixed it my self
In php.ini find “ error_reporting = E_ALL”

Here replace this with “error_reporting = E_ALL & ~E_NOTICE & ~E_WARNING “
Thats it!
may this post help others
maxx99
Forum Contributor
Posts: 142
Joined: Mon Nov 21, 2011 3:40 am

Re: Undefined index: login_user in D:\wamp\www\index.php on

Post by maxx99 »

You should check if that index exists with isset or empty instead of turning off error_reporting :)
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Undefined index: login_user in D:\wamp\www\index.php on

Post by social_experiment »

maxx99 makes a good point; the OP doesn't mention about any checking (which they might be doing) but if not it's a better option to do checking instead of hiding the error. For production it's better to see an error and take care of it. For live site purposes, it's better to hide the errors (if you have taken care of them) because you don't want visitors seeing the errors
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply