How to feed an input with a get variable in php

Asked

Viewed 13,476 times

2

Hello everyone all right I hope so, I’m with a relatively simple doubt, what I’m wanting is to use a file to make insertion and also change in php regarding the insertion is trackilo, well what I would like to assign the values I pass via $_GET[''] for the form so it shows the values I’ve already selected that are in my url to be able to actually change the id passed.

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

someone has been there, HELP.

  • Some of these answers answered him?

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.

  • in the case of '''$name'''.

  • How I make a value assignment André?

1

In principle you only need

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

taking into account that you should always treat content that comes via $_GET before you use it.

0

Extending member Sergio’s response, this is the basic cleaning performed with values from user inserts, later you must pass the values through validation chains (using if for example).

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

fine validation example.

if (array_key_exists("email", $_GET)) {
    //
}

Browser other questions tagged

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