Ok this may be a little late but here's how I did it anyway - might be bit of a long way to do it but it worked for me
On the student reg page - run 3 queries in this order:
(assuming you already have declared variables where you are going to store the sno and cid)
1st query - insert all the form data into the student table (sno is automatically generated here)
2nd query - find out what sno has just been generated - match the email address for example straight from the form data you just received - select sno where email = ".$_POST['email']
3rd query - you already have the cid from the form data (assuming your select values = the cid corresponding to the course table), all you now need to do is: insert into course_student table (sno, cid) VALUES (post form variables)..
Hope that helps.