You need to have the flash post the variables to the processing script.
In the script you grab the posted variables:
$name = $_POST['name'];
and you have to insert them into the database:
insert into MyTable (name, code) values ($name, $code)
For the random value you need a function like [man]mt_rad()[/man]
You should be able to get going from here. If you cant..
Read the manual.. Try.. Test.. Read the guidelines.. , Post again. And then we will see what is going wrong with your code.
This is not a tutorial forum, this is not a we-built-the-site-for-you forum. But if you cannot get things to work, we can help.
J.