I have created a page with 2 drop down boxes dynamically filled with mysql data...having a problem though inserting into the table I need to in the db and can't see why, pretty sure I'm just overlooking something easy.... heres my code:
<?php
include('db_connect.php');
session_start();
session_register();
$SESSION["name"];
if (isset($SESSION["uid"]))
{
echo nl2br("Welcome Test System! \n");
}
?>
<html>
<head>
<title></title>
</head>
<body>
<p align="center"><big><big>/big></big></p>
<form method="POST" action="<?=$_SERVER['PHP_SELF']?>">
<div align="center"><center><p>Username: <select name="user" size="1">
//INSERT a dropdown list with all valid usernames in the database
</script><script language="php">
$query = "SELECT username FROM users WHERE companyid = '$company'";
$result = mysql_query($query) or die();
if(mysql_num_rows($result)) {
while($row = mysql_fetch_row($result))
{
print("<option value=\"$row[0]\">$row[0]</option>");
}
} else {
print("<option value=\"\">No users created yet</option>");
}
</script>
</select></p>
<p>Course Name :
<select name="course" size="1" id="course">
<script language="php">
</script><script language="php">
$query2 = "SELECT coursename FROM Courses";
$result2 = mysql_query($query2) or die();
if(mysql_num_rows($result2)) {
while($row2 = mysql_fetch_row($result2))
{
print("<option value=\"$row2[0]\">$row2[0]</option>");
}
} else {
print("<option value=\"\">No Courses created yet</option>");
}
</script>
</select>
</p>
<p>Date to be Taken By:
<input name="date" type="text" id="date">
</p>
<p>
<input type="submit" value="Assign Course">
</p>
</center></div>
</form>
</body>
</html>
<?php
$sql = "INSERT INTO Assignments SET
userid = '',
username = '$POST[user]',
courseid = '',
coursename = '$POST[course]',
datetakenby = '$_POST[date]'";
mysql_query($query) or die (mysql_error());
?>