Page 1 of 1

Always show Notice: Undefined index:?

Posted: Fri Jul 25, 2003 9:54 am
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.

Posted: Fri Jul 25, 2003 11:38 am
by AVATAr
try ussing if(isset($gender)){ ...

the problem is that $gender is not set

Thank you

Posted: Sat Jul 26, 2003 12:17 am
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.

Posted: Sat Jul 26, 2003 5:37 pm
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