Home > Enterprise >  SQL WHERE Input field
SQL WHERE Input field

Time:08-14

 <input type="text" name="lastn" style="width:20%;" placeholder="Nachname" >
 <input type="submit" name="submit" value="Suchen">

       $lastn = $_POST['lastn'];
        $sql = "SELECT * FROM `Security_BNB` WHERE lastn='". $lastn. "'";

How do I get it to have the entry from the input field behind WHERE lastn =?

CodePudding user response:

Without more information bit hard to help, but is your form method set to post as the default is get

<form method="post">

CodePudding user response:

Im not quite sure what you are asking, But from what I can gather, the solution to your question is:

<form action="path/To/PHP/File.php" method="POST">
    <input type="text" name="lastn" style="width:20%;" placeholder="Nachname" >
    <input type="submit" name="submit" value="Suchen">
</form>

File.php:

<?php
if (isset($_POST['submit'])){
   $lastn = $_POST['lastn'];
   $sql = "SELECT * FROM `Security_BNB` WHERE lastn='". $lastn. "'";
}

?>
  • Related