Noob here...
I have a drop down form, which is populated by the results of a sql query.
When someone makes a selection from this dropdown, I would like the results inserted into a sql table.
Here is the form...
<?php
include 'dbaccess/config.php';
include 'dbaccess/opendb.php';
echo "<html>
<head><title>Late Room Form</title></head>
<body>";
$query = "SELECT student_id, first_name, last_name FROM student_info";
$result = mysqli_query($cxn, $query)
or die ("Couldn't execute query.");
echo "<form action='formhandle.php' method='POST'>";
echo '<select name="selectName">';
echo '<option value="optionValue">--Select--</option>';
while($opt = mysqli_fetch_assoc($result))
{
echo '<option value="studentRecord">'.$opt['last_name'].' , '.$opt['first_name'].' , '.$opt['student_id'].'</option>';
}
echo '</select>';
echo "<input type='submit' value='Submit'>";
echo "</form>";
include 'dbaccess/closedb.php';
?>
</body></html>
Here is what I tried to do for the formhandle.php...
<?php
include 'dbaccess/config.php';
$query = "INSERT INTO consequence (student_id)
VALUES ('$_POST[$studentRecord]')";
$result = mysqli_query($cxn,$query)
or die ("Couldn't execute query.");
echo "Update Seccessful!";
?>
This results in a blank array.
Can someone please help me figure out how to handle the $_POST data so it can be inserted into the database?
Thanks!