When a successful register happens there is an Insert into members table. It has an id filed auto increment.
//Create INSERT query
$qry = "INSERT INTO members(email, passwd) VALUES('$email', '$password')";
$result = mysql_query($qry);
Because I need to save some of the input in another table named companies, I find the total records ( that means the last ID)
//find lastid from members
$lastid = mysql_fetch_array(mysql_query("select count(id) as lastid from members"));
$lastid = $lastid[lastid];
and save it into the table companies.
//Insert lastid to Companies
$insertit = mysql_query("INSERT INTO companies( id, name) VALUES('$lastid', '$cname' )");
This is working successfully but is there a better way of doing this ? I have removed some of the fields to give a better more to the point example.