I'm not sure if I understand correctly what you are trying to do. This page will submit to another page, where you want the selected module_details to go into the users table, but you want the module_id that matches the module_details, correct?
If so, you will probably have to run two queries. The code should look similar to this, so you should at least be able to see what's going on.
$result = mysql_query("SELECT `module_id` FROM `modules` WHERE `module_details` = 'the module_details from the form';");
$row = mysql_fetch_row($result);
$insert = mysql_query("INSERT INTO `users` VALUES('','" . $row[0] . "');");
This will obviously have to be changed slightly to work with your database and your form...