Page 1 of 1

simple undefined index error

Posted: Mon Aug 23, 2010 5:50 am
by paulmilner
Hi
I have a line in a page which recieves form info from a form page

Code: Select all

$additional_info1 = $_REQUEST['additional_info1'] ;
the problem is, if the form which posts to this page does not have the form field 'additional_info1' then it throws up an undefined index error.

How can I stop this error without having to include the 'additional_info1' form field on the form page. This is one of many form fields which react in this way which I would like to only add only on specific pages which post to this php script
Thanks
Paul M

Re: simple undefined index error

Posted: Mon Aug 23, 2010 8:31 am
by shawngoldw

Code: Select all

$additional_info1 = isset($_REQUEST['additional_info1'] ) ? $_REQUEST['additional_info1']  : "";

If it isn't submitted $additional_info1 will equal ""



Shawn

Re: simple undefined index error

Posted: Mon Aug 23, 2010 11:39 am
by paulmilner
Thanks Shawn
That sorted it

Paul M