Values of $_REQUEST returning null

Asked

Viewed 60 times

1

I got 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 take the field: deseja_fixo then I do this in mine php:

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

only then it doesn’t print anything on my screen and when I do var_dump($val), have NULL in response.

  • 1

    array(1) { ["fixed"]=> array(3) { [""'numero'"]=> string(5) "xxxxx" ["'g_actual_fixed'"]=> string(4) "yyyy" ["'wish fixed'"]=> string(1) "2" } }

  • 1

    enter the code of your shipping form, help in understanding the problem!

  • @Henriquesilva makes a test like $val = (string)$_REQUEST['fixed']['fixed wish'];

  • return NULL

  • Thanks for the personal tips I got

1 answer

4


You should remove the quotes from the form fields' names and look like this:

name="fixo[deseja_fixo]" and not like this name="fixo['deseja_fixo']"

  • Thanks man I was super stressed already, lost hours because of kkkkk quotes

  • It’s already happened to me, because of the quotation marks :-)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.