I have done it...... but then also it is not working.... I want it should enter the state_id from the state table.... I have done some modifications.... <? //ob_start(); session_start(); //include("../conn/config.php"); //include("../conn/dbclass.php"); $conn = mysql_connect('localhost','root','root') or die(mysql_error()); mysql_select_db('searchindia'); //$objDB=new dbclass(); $city_id = $_POST['city_id']; $state_id = $_POST['state_id']; $city_name = $_POST['city_name']; $statename = $_POST['state']; ///state is the dropdown box name/// $state = "SELECT state_id FROM state WHERE state_name = $state_id"; $state1 = mysql_query($state); $sql = " INSERT INTO city SET city_id='".$city_id."', state_id='".$state1."', city_name='".$city_name."'" ; //$objDB ->dbclass(); $a = mysql_query($sql) or die(mysql_error()); ?> <?php header('Location: indexlocation.php'); ?> <script> //window.location='index.php?p=location'; </script> <form action="indexlocation.php"></form>