mysqli_insert_id() function returns the id generated by a your query on a table with a column having the AUTO_INCREMENT attribute.
Performing an INSERT or UPDATE statement using the LAST_INSERT_ID() function will also modify the value returned by the mysqli_insert_id function.
$result = mysqli_query($con, $qry);
$userid = mysqli_insert_id($con); // it auto generate the pro_id which you want to insert into product size table as a froegin key.
//echo "user id = ".$userid;
$prosize = $_POST['size'];
$qry1 = "insert into product_size (pro_size, user_id) values('$prosize','$userid')";
echo $qry1;
$result1 = mysqli_query($con, $qry1) or die(mysqli_error());
if($result1)
{
echo "successful";
}
else {
echo "error";
}