0
I have 7 buttons of Submit in a form. Being:
Four of that:
<input type="submit" id="chamado1" class="mr-abre-btn" value="Abrir chamado">
Two of this:
<input type="submit" id="chamado2" class="mr-abre-btn" value="Encaminhar chamado">
And one of that:
<input type="submit" id="chamado3" class="mr-encerra-btn" value="Encerra chamado">
The problem is that I’m trying to make a switch case or an if in the value of a input hidden
that I have. I’m doing it this way:
<input type="hidden" name="situacao_id" value="
<?php
$situacao_chamado = $_POST['id'];
switch ($situacao_chamado) {
case 'chamado1':
echo "1";
break;
case 'chamado2':
echo "3";
break;
case 'chamado3':
echo "3";
break;
}
?>"
However, when I look for this variable:
$situacao_chamado = $_POST['id'];
Ends up generating the error below:
Notice: Undefined index: id in C:\wamp64\www\form\formulario.php on line 167 Call Stack #TimeMemoryFunctionLocation 10.0010242264{main}( )...\formulari.php:0 20.0111307088include( 'C:\wamp64\www\form\formulario.php' )...\formulario.php:44 ">
What is the need for 7 buttons? Why are there repeated buttons? Know the attribute value
id
is not passed to PHP through the request. The only values will be the pairname
/value
. In doing$_POST["id"]
you are trying to take the value of a field withname="id"
, that does not exist in the question. If this amount of buttons actually makes sense, set the attributename
and check it in PHP. Remember that the value will bevalue
, nayid
.– Woss
@Andersoncarloswoss, I need several input, because the form is dynamic, are yes and no questions and depending on the answer leads to another question, so he has in certain question the closure of the call or opening of the call. And Inputs appear in certain questions. It was the most objective way I could create. Thanks for the tip.
– Marcelo Rossi