Yep, you guess correct.
Insert into the customer, capture the id used by issuing a mysql_insert_id(), do the same with the computer (make sure you issue a query call though as neither of these two currently do). Then take each of those, and use them as the necessary values in the contract during the insertion.
Also, mysql library is nearing EOL; you should consider using mysqli or PDO for your mysql work. Since the current code you have is susceptible to sql injection, you should look at using prepared statements for the mysqli or pdo library and go from there.
header('HTTP/1.1 420 Enhance Your Calm');