Well, you don't seem to use two pages, but only one... you have to use 2 pages (or the same page with 2 different parts, but let's forget that idea at the moment)... So let's have two pages : page1.php and page2.php
page1.php :
<?php
// Of course, here comes the code to connect to the DB.
$query = "SELECT categorydescription, categoryname FROM categories ORDER BY categoryname ASC";
$result = mysql_query($query,$conn) or die('Query failed: ' . mysql_error());
?>
<form method="post" action="./page2.php">
<select name="categoryname" id="categoryname">
<?php
while ($line = mysql_fetch_array($result, MYSQL_NUM)) {
// Before careful, there was an unuseful space after « value=" »...
echo "<option value=\"$line[0]\"> $line[1] </option>" ;
}
?>
</select>
<input value="Submit" type="submit" />
</form>
<?php
mysql_free_result($result);
?>
page2.php
<?php
// Of course, here comes the code to connect to the DB.
$strCategory_Name = mysql_real_escape_string($_REQUEST['categoryname']);
$query ="INSERT INTO orderdetails (CategoryName)
VALUES('$strCategory_Name')";
mysql_query($query) or die(mysql_error());
?>
mysql_real_escape_string() is used to make sure that the string won't corrupt the table (hackers could do some bad stuff)... it simply replaces quotes with \' or \", and some other things...
Was I clear or do you need more info ?