Always show Notice: Undefined index:?

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
Herrien
Forum Newbie
Posts: 2
Joined: Fri Jul 25, 2003 9:54 am

Always show Notice: Undefined index:?

Post by Herrien »

Hi all,

I am a newbie in PHP, so i mught sound a bit stupid hope you guys dont mind.

I have a form with some checkbox,radio button and textfield,

Whenever a checkbox or radio button is untick or no value, i will get
Notice: Undefined index: gender in c:\script.php on line 17

but whenever i tick it the notice will be gone.

whereas for textfield, even if it is left empty no Notice will be shown.

Thanks for any help, sorry for any inconvenience.
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

try ussing if(isset($gender)){ ...

the problem is that $gender is not set
Herrien
Forum Newbie
Posts: 2
Joined: Fri Jul 25, 2003 9:54 am

Thank you

Post by Herrien »

It works but there is another question here, (sorry for me asking too much)

How come for textfield there isn't such notice even if left blank?

Sometimes when i read up some forum post i saw that values from a form passed to a php file can be hidden.

What go they mean by hidden values, is it for security?

Thanks for any help.
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

1- textfield: you can use if (trim($txtfield) == '') { echo "its empty";}

2- hidden fields, its not for security... they use it if you want some value to be passed by POST method
Post Reply