Page 2 of 2

Posted: Fri Aug 19, 2005 5:29 am
by korto
try using $_REQUEST instead of $_POST and let me know (how are you submitting the form and what is the form action and method?)

Posted: Fri Aug 19, 2005 5:36 am
by pleigh
korto wrote:try using $_REQUEST instead of $_POST and let me know (how are you submitting the form and what is the form action and method?)
this is my code so far, still undefined index...

Code: Select all

<select name='companyrole'>
<option value=''> - Select Company's Role - </option>
<option value='Contractor' <? if ($_REQUEST['companyrole'] == 'Contractor') echo "selected"; ?>>Contractor</option>
<option value='Sub-Contractor' <? if ($_REQUEST['companyrole'] == 'Sub-Contractor') echo "selected"; ?>>Sub-Contractor</option>
<option value='Outsourcing' <? if ($_REQUEST['companyrole'] == 'Outsourcing') echo "selected"; ?>>Outsourcing</option>
</select>
here's the orm action/method code

Code: Select all

<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post" >

Posted: Fri Aug 19, 2005 5:53 am
by korto
That is not an error that would normally prevent the page from displaying correctly, it depends on the conf. But anyway try this:

Code: Select all

<? if(!isset($_POST['companyrole']))	{
		$companyrole = '';
	}
	else	{
		$companyrole = $_POST['companyrole'];
	}
?>
<select name='companyrole'>
<option value=''> - Select Company's Role - </option>
<option value='Contractor' <? if ($companyrole == 'Contractor') echo "selected"; ?>>Contractor</option>
<option value='Sub-Contractor' <? if ($companyrole == 'Sub-Contractor') echo "selected"; ?>>Sub-Contractor</option>
<option value='Outsourcing' <? if ($companyrole == 'Outsourcing') echo "selected"; ?>>Outsourcing</option>
</select>
It puts sends the $_POST['companyrole'] to a variable named $companyrole and if $_POST['companyrole'] is not set - which is the case when you first load the page- it passes an null value so that you won't get the error message.

Posted: Fri Aug 19, 2005 6:20 am
by pleigh
that is so brilliant....thanks a lot... : :D