How to feed an input with a get variable in php

2

Hello everyone, I hope so, I have a relatively simple question, what I am wanting is to use a file to do insert and also change in php referring to the insertion is traquilo, well what I would like would be to assign the values that I pass via $_GET[''] to the form so the same show the values that I already did the select that are in my url to be able to make the actual change of the last id.

<input class="input" type="text" name="nome">

Someone has already gone through this, HELP.

    
asked by anonymous 20.05.2015 / 06:59

3 answers

1

Solved simple problem.

<?php $nome = (!empty($_GET['nome']) ? $_GET['nome'] : ''); ?>
<input class="input" type="text" value="<?php echo $nome; ?>" name="nome">

Thank you.

    
20.05.2015 / 07:13
1

In principle you need only

$nome = $_GET['nome'];
echo '<input class="input" type="text" name="nome" value="'.$nome.'"/>;'' 

Given that you should always treat content that comes via $_GET before you use it.

    
20.05.2015 / 07:14
0

$email = (trim(strip_tags($_GET['email'])));
echo '<input class="input" type="text" name="nome" value="'.$email.'"/>;'
  

Example of finer validation.

if (array_key_exists("email", $_GET)) {
    //
}
    
20.05.2015 / 13:17