antoinv10 antoinv10 - 7 months ago 8
PHP Question

Put php value in html field after query has been executed

I'd like to put a value in my text boxes that I get from a php query, but when I do it the values I want to put in my text boxes are not set. Does anyone know how I could do this ?
Here is my code :

Nom : <input type="text" name="nom" value="<?php if(isset($nom)){echo htmlspecialchars($nom);} ?>"/>


Thanks

Answer

Try this one:

    <?php 
    $nom = $_POST['nom'];
    if (isset($nom)){ 
        $new = htmlspecialchars($nom);
    } 
    ?>

    <input type="text" name="nom" value="<?php echo $new; ?>" />