I am trying to get the option value from a selectbox but is isn’t working:
HTML:
<form action="" method="post" name="module_gen">
<select id="module_gen_select_ver" name="module_gen_select_ver">
<option value="joomla15">Joomla 1.5</option>
<option value="joomla25_30">Joomla 2.5/3.0</option>
</select>
</form>
PHP:
if(isset($_POST['module_gen_select_ver'] ) == 'joomla15') {
$xmldata = '</install>';
}
elseif(isset($_POST['module_gen_select_ver'] ) == 'joomla25_30') {
$xmldata = '</extension>';
}
Wne I click the submit button, it doesn’t seem to be taking the value of the option into account.
Can anyone show me as to where I have gone wrong?
Your if conditions are wrong.
is getting the return value of
isset($_POST['module_gen_select_ver'] ), which is a boolean, then comparing it to'joomla15', so the condition is not met. It should be:The condition is still safe, as if it isn’t set, the second condition won’t even be read for all intents and purposes.
Or you could simply wrap both the if and elseif in
if(isset($_POST['module_gen_select_ver'])then removing it from the if and the elseif, Thusly: