How to get the value of the textbox?

0

I want to get the value I'm going to write in my textbox . Everything on the same page to then change a table field by the value entered in textbox .

<form method="POST" action="#">

    <input type=text required name='txtnewpass' autofocus style='width:150px' value='<?php echo "$txtnewpass"; ?>'>
    <input type=submit name=Alterar value=Alterar>

</form>

PHP

if ($_POST['txtnewpass']){
 $txtnewpass = $_POST['txtnewpass'];
}

$base_hndl  =   new SQLite3($dir.$base);
$requete = "UPDATE 'users' SET 
            password='$txtnewpass'
            WHERE login='$login'";
$resultat = $base_hndl->exec($requete); 
echo "<br><b><center>password change</center></b>";
    
asked by anonymous 05.11.2014 / 13:39

1 answer

1

Put the whole code inside the if. If you do not receive values you do not want me to update the database.

if ($_POST['txtnewpass']){
    $txtnewpass = $_POST['txtnewpass'];

    $base_hndl  =   new SQLite3($dir.$base);
    $requete = "UPDATE 'users' SET 
                password='$txtnewpass'
                WHERE login='$login'";
    $resultat = $base_hndl->exec($requete); 
    echo "<br><b><center>password change</center></b>";
}
    
05.11.2014 / 16:30