Passing of values by variable does not work

0

I'm using the MDL framework (google) to make a registration system, and in the part of changing the information in the database, in passing the values through the url, only some are passed and some are not. In addition, the first and last names do not appear in the form, although the url has received both. Here is the code: page that shows the data (clients.php):     

    $seleciona="select * from cadastro_clientes";
    $sql=mysqli_query($con,$seleciona);
        while ($reg=mysqli_fetch_assoc($sql)) {
        echo "
         <tr>
        <td class=mdl-data-table__cell--non-numeric>$reg[nome]</td>
        <td class=mdl-data-table__cell--non-numeric>$reg[endereco]</td>
        <td class=mdl-data-table__cell--non-numeric>$reg[numero]</td>
        <td class=mdl-data-table__cell--non-numeric>$reg[dada_comemorada]
        </td>
        <td class=mdl-data-table__cell--non-numeric>
        <a href=form_edit.php?ru="
        .urlencode($reg['nome']).
        "&en=".urldecode($reg['endereco']).
        "&nu=".urldecode($reg['numero']).
        "&da=".urldecode($reg['dada_comemorada']).
        ">Editar</a></td>
        </tr>";
                }

                ?>  

page that should show data to change (form_edit.php):

       <?php
       include"conecta.inc";
       $recebenome=$_GET['ru'];
       $recebeendereco=$_GET['en'];
       $numero=$_GET['nu'];
       $data=$_GET['da'];
       ?>


     <div class="page-content">
            <form action="cadastrar.php" method="post" name="cadastro">
              <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                <input class="mdl-textfield__input" type="text" id="sample3" name="nome" value=<?php echo $recebenome;?>>
                <label class="mdl-textfield__label" for="sample3">NOME</label>
              </div><br>
              <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                <input class="mdl-textfield__input" type="text" id="sample3" name="endereco" value=<?php echo $recebeendereco;?>>
                <label class="mdl-textfield__label" for="sample3">ENDEREÇO</label>
              </div><br>
              <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                <input class="mdl-textfield__input" type="text" id="sample3" name="numero" value=<?php echo $numero;?>>
                <label class="mdl-textfield__label" for="sample3">NUMERO</label>
              </div><br>
              <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
                <input class="mdl-textfield__input" type="text" id="sample3" name="data" value=<?php echo $data;?>>
                <label class="mdl-textfield__label" for="sample3">DATA COMEMORADA</label>
              </div><br>

                <input type="submit" value="SALVAR" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent">

            </form>

          </div>

In the url the first and last name passes, but does not appear in the form, and the number and date give the error "Notice: Undefined index: nu in C: \ xampp \ htdocs \ Bjorn \ form_edit.php on line 5", but if I register some client without space, all appear normally. I do not know why, since I used urlencode: /

note, when I click on the client that is without writing without separating the words by space:

NowwhenIclickontheregisteredclientwithspacesseparatingthefirstandlastnames,andtheaddress(notethattheurlreceivesthefirstandlastnamebutnotthefulladdress:

    
asked by anonymous 22.07.2017 / 10:36

1 answer

0

The first step is to put URLENCODE for all parameters.

<a href=form_edit.php?ru="
.urlencode($reg['nome']).
"&en=".urlencode($reg['endereco']).
"&nu=".urlencode($reg['numero']).
"&da=".urlencode($reg['dada_comemorada']).
">Editar</a>

And the second provision is on page (form_edit.php):

  

The space will become an attribute separator and everything after the space will be seen as an attribute of the input element.

The solution is to encircle all input values:

example value="<?php echo $recebenome;?>"

<input class="mdl-textfield__input" type="text" id="sample3" name="nome" value="<?php echo $recebenome;?>">

  

If you check the source code - without the quotation marks in the values - you will see that the inputs are entered correctly, but only the first part appears in the page view. will be submitted to the cadastrar.php page.

<input type=text id=sample3 name=endereco value=Fulano de Tal>

<input type=text id=sample3 name=endereco value="Fulano de Tal">
  

Another example: imagine that my name is Fulano style=color:red to pass correctly my name has to be enclosed with quotation marks otherwise style=color:red will be interpreted as input element attribute.

<input type=text id=sample3 name=endereco value="Fulano style=color:red">

<input type=text id=sample3 name=endereco value=Fulano style=color:red>
    
22.07.2017 / 20:54