How to get id of recently submitted record?

Hi all!
With due respect to rajug and webgypsy, I found this code in Sitepoint itself.:slight_smile:
This code generates member numbers;

<?PHP
$my=mysql_connect("localhost","root","");
mysql_select_db("lab",$my);
$query=mysql_query("SELECT stud_master_initial, stud_master_cource, stud_master_batch, stud_master_id  FROM student_master WHERE stud_master_id=$id ");
while($row=mysql_fetch_array($query))
{
$ini=$row['stud_master_initial'];
$cource=$row['stud_master_cource'];
$batch=$row['stud_master_batch'];
$stud_id = $row['stud_master_id'];
$no= strtoupper($ini) . '-' . ($cource) . '-' .($batch) . '-' .$stud_id;
echo $no;
}
?>

I wanted to display this Member Number after submission of the registration form.Something like, “Registered successfully, your member no is ???”.
But how can I fetch the data which I have submitted recently?
I dont know how to run a query like:
“SELECT * FROM student_master WHERE stud_master_id=$id”
What can be $id if I have just submitted the form??

mysql_insert_id()

Yeh its working.Thx.