When I select one or more of the possible checkbox
, it shows me the message or messages that I have in PHP
, but if I do not select any of the possible checkbox
I get the following error:
"Notice: Undefined index: TypeM in C: \ xampp \ htdocs \ Task_02 \ action.php on line 11"
Line 11
$TipoM=$_POST["TipoM"];
How can I solve this error?
I enclose fragments of my codes:
HTML form
Elige tipo de mensaje: <br><br>
<select multiple name="TipoM[]">
<option value="Top_Secret" checked>Alto secreto</option>
<option value="Reserved">Secreto</option>
<option value="Indifferent">Indiferente su difusión</option>
<option value="Obligatory">Difusion obligatoria</option>
</select><br><br>
PHP CODE
function Mostrar_TipoMensaje ($TipoM)
{
for ($i=0;$i<count($TipoM);$i++)
{
if(($TipoM[$i])==("Top_Secret"))
echo 'TOP SECRET<br>';
else
echo("");
if(($TipoM[$i])==("Reserved"))
echo 'RESERVED<br>';
else
echo("");
if(($TipoM[$i])==("Indifferent"))
echo 'INDIFFERENT<br>';
else
echo("");
if(($TipoM[$i])==("Obligatory"))
echo 'OBLIGATORY<br>';
else
echo("");
}
}