database - Session Id's are inconsistent across multiple php files -


i have created 2 simple php files populates data entered users database. using sessions , have entered session_start(); in php files @ first line (no commented line @ top). however, code works in local server (mamp) when host online public access face problem. code works fine i.e session id remains same, second php file creates different session id's , hence data first php file gets entered database. please me out may cause in inconsistency in sessions?

<-- code first php--> <?php session_start(); $val = session_id(); echo ($val); define ('db_name', 'roze'); define('db_user', 'root'); define('db_password', 'good'); define('db_host', 'localhost');  $link = mysql_connect(db_host, db_user, db_password);  if (!$link) {  die('could not connect: ' . mysql_error());  }  $db_selected = mysql_select_db(db_name, $link);  if (!$db_selected) { die('cannot use' . db_name . ': ' . mysql_error()); }  echo 'connected successfully';   $value1 = $_post['gender']; $value2 = $_post['age']; $value3 = $_post['occupation'];  $sql = "insert master (sess_id, gender, age, occupation) values     ('$val','$value1', '$value2', '$value3')"; if (!mysql_query($sql)){ die('error: ' . mysql_error()); } header('location: main.html'); ?>  <-- code second php file-->  <?php session_start();   $val = session_id(); echo ($val);  define ('db_name', 'roze'); define('db_user', 'root'); define('db_password', 'good'); define('db_host', 'localhost');  $link = mysql_connect(db_host, db_user, db_password);  if (!$link) {  die('could not connect: ' . mysql_error());  }  $db_selected = mysql_select_db(db_name, $link);  if (!$db_selected) { die('cannot use' . db_name . ': ' . mysql_error()); }  echo 'connected successfully';    $value5 = $_post['lamp'];  $sql = " update master set lamp= '".$value5."' sess_id='".$val."' ";  if (!mysql_query($sql)){ die('error: ' . mysql_error()); }  //header('location: main.html');   ?> 


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -