0

Im trying to create a form with drop down which is populated from database, when i select the value and i press submit i get an error as described below please i need some help.

<!DOCTYPE HTML>
    <html>
    <head>
    </head>
    <body>

    <h2>Test</h2>
    <form method="post" action="pass.php">


        Name: <select  name="title_name">
            <?php
            require_once ('conn.php');
            $sql = mysqli_query(db_connect(), "SELECT Title FROM $table WHERE NOT Status='Links_added' ORDER BY Title ASC");
            echo "<option value=\"name1\">" . "Select Title" . "</option>";
            while ($row = $sql->fetch_assoc()){
                echo "<option value=\"name2\">" . $row['Title'] . "</option>";
            }
            ?>
        </select>
        <br><br>
        <input type="submit" name="submit" value="Submit">

    </form>
    </body>
    </html>

pass.php

<?php
echo $_POST["title_name"];

enter image description here

Error

Notice: Undefined index: title_name in pass.php on line 2

When i add to pass.php this :

<?php
if (isset($_POST['submit'])) {

    echo $_POST["title_name"];
}

I dont get any response, why there is no data after i select and submit the form ?!

0 Answers0