I have created 2 tables called "User_Info" & "Auth_Users".

In "User_Info" table "ID" is the primary key. In "Auth_Users" table "ID" is the foreign key.

I have created a "User Form" through which I am trying to capture the data. Since the primary key is an auto_increment value I don't have to insert that in the "User_Info" table.

In the "User Form" I have fields like - Firstname, Lastname, Phone, Email & Password. I am trying to break this fields and Insert "firstname, lastname, phone" in "User_Info" table and "Email & Password" in "Auth_Users" table.

Besides this, i also want to insert the same "ID" number from "User_Info" table to "Auth_Users" table "ID" field.

I couldn't get it solved. Please help me.

$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());

mysql_query("INSERT INTO userinfo (col1) values ('value1')");
$keyid= mysql_insert_id());

mysql_query("INSERT INTO auth_user (uid,col1) values ('{$keyid}','value1')");


thank you, I will try that out.