$ _REQUEST values returning null [closed]

1

I have the following form that sends an array:

Form:

    <form id="form-simulacao" action="controller.php">
<div  class="col-md-3">
    <div class="form-field">        
            <div class="form-group">
                <label>Nº do Fixo:</label>
                <input class="form-control" type="text" name="fixo['numero']">
            </div>

            <div class="form-group">
                <label>Gasto Atual:</label>
                <input class="form-control" type="text" name="fixo['g_atual_fixo']">
            </div>

            <div class="form-group">
                <label>Quanto gostaria de gastar:</label>
                <input class="form-control" type="text" name="fixo['deseja_fixo']">
            </div>
    </div>
</div>
    <button class="btn btn-default">envia</button>
        </form>
Array
(
    [fixo] => Array
        (
            ['numero'] => xxxxx
            ['g_atual_fixo'] => yyyy
            ['deseja_fixo'] => 2
        )

)

I need to get the field: deseja_fixo then I do the following in my php :

$val = $_REQUEST['fixo']['deseja_fixo'];
echo $val;

But it does not print anything on my screen and when I do var_dump($val), I have NULL in response.

    
asked by anonymous 02.09.2016 / 20:16

1 answer

4

You should take the quotation marks out of the form field names like this:

name="fixo[deseja_fixo]" and not so name="fixo['deseja_fixo']"

    
02.09.2016 / 20:55