title: Unable to insert the generated random id into database
body: <p>I am trying to get the value of the random id from another page through session, but while inserting into the database it doesn’t get inserted into database. It’s zero, here is the code:</p>
  
  <pre><code>Stud.php
       &lt;?php  
                  session_start();
                  $seed = str_split('abcdefghijklmnopqrstuvwxyz1234567890');
                  $rand = array_rand($seed, 7);
                  $convert = array_map(function($n){
                  global $seed;
                  return $seed[$n];
                  },$rand);
                  $var = implode('',$convert);
                  echo $var;
                  //echo "&lt;blink&gt;Your Complaint is is:".$var."&lt;/blink&gt;";
                  // $_SESSION['varname'] = $var;
                  // unset($comment);
  
              ?&gt;
  </code></pre>
  
  <p><em>Insert.php</em></p>
  
  <pre><code>&lt;?php
  session_start();
  include 'library/dbconnect.php';
  $_SESSION['varname'] = $var;
  $var_value = $_SESSION['varname'];$name=$_POST['Studname'];
  $district=$_POST['district'];
  $school_name=$_POST['School_name'];
  $standard=$_POST['std'];
  $division=$_POST['Division'];
  $complaint=$_POST['Complaint'];
  $entryDate=$_POST['date'];
  $dateEntry=explode('-',$entryDate);
  $date1=$dateEntry[2]."-".$dateEntry[1]."-".$dateEntry[0];
  echo $name."&lt;br /&gt;".$district."&lt;br /&gt;".$date1."&lt;br /&gt;";
  $query2="INSERT INTO `Complaint_register`(`complain_Id`,`entrydate`, `studname`,
  `District`, `School_name`, `Standard`, `Division`, `Complaint`, `status`) VALUES 
  ('$var_value','$date1','$name','$district','$school_name','$standard',
  '$division','$complaint',1)";   
  $result2=mysql_query($query2)or die(mysql_error());
  $query3="SELECT * FROM Complaint_register";
  $result3=mysql_query($query3);
  $num=mysql_numrows($result3);
   if($result2)
  {
  $coment= $num.' Complaint Successfully Registered';
  header("Location:stud.php");
  
  }
  ?&gt;
  </code></pre>