title: php setting session variables from form
body: <p>This is my main report page where I am sending session variables to another php page. I am running into issues when I try and post the form data to the session variables because then the query returns nothing. I have been searching and tinkering for a few days now but no results. </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
      &lt;?php
        session_start();
       /* this works when the session variables are static*/
       $_SESSION["date"] = '2012-05-01'; 
       $_SESSION["ServiceOrders"] ='Network Error';  
       /* when I try and post the form values the query returns nothing
        $_SESSION["date"] = $_POST['sdate']; 
        $_SESSION["ServiceOrders"] =   $_POST['ServiceOrders']; 
       */
  
      ?&gt;
      &lt;html&gt;
  
    &lt;head&gt;   
        &lt;link rel='stylesheet' type='text/css' href='styles.css' /&gt;
        &lt;link rel="stylesheet" href="grid.css" type="text/css" /&gt;
        &lt;link rel="stylesheet" href="backgroundcss.css" type="text/css" /&gt;
  &lt;style&gt;
  form { width: 700px; }
  label { float: left; width: 100px; }
  input[type=text] { float: left; width: 200px; }
  .clear { clear: both; height: 0; line-height: 0; }
  .floatright { float: right; }
  
  &lt;/style&gt;
  
      &lt;script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js'&gt;&lt;/script&gt;
      &lt;script type='text/javascript' src='menu_jquery.js'&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="jquery-1.9.1.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="https://www.google.com/jsapi"&gt;&lt;/script&gt;
      &lt;link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"&gt;
      &lt;script src="//code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt;
      &lt;script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"&gt;&lt;/script&gt;    
  
  &lt;script&gt;
    $(function() {
      $( "#datepicker" ).datepicker();
    });
  
   $(function() {
       $("#refresh").on("click", function() {
          $("#mydiv").load("http://***.***.***.***/ServiceOReport.php");
          return false;
      })
    })
  
  &lt;/script&gt;
  
    &lt;/script&gt;
    &lt;/head&gt;
  
    &lt;body  class="container"&gt;
    &lt;br&gt;
  &lt;div id='menu'&gt;
  &lt;ul&gt;
     &lt;li class='active'&gt;&lt;a href='LineChart.php'&gt;&lt;span&gt;Home&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
     &lt;li class='has-sub'&gt;&lt;a href='#'&gt;&lt;span&gt;Contacts&lt;/span&gt;&lt;/a&gt;
        &lt;ul&gt;
           &lt;li&gt;&lt;a href='allrows.php'&gt;&lt;span&gt;Inbound Calls Codes&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
           &lt;li class='last'&gt;&lt;a href='#'&gt;&lt;span&gt;Contact Free Form&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
     &lt;/li&gt;
     &lt;li class='has-sub'&gt;&lt;a href='#'&gt;&lt;span&gt;Service Orders&lt;/span&gt;&lt;/a&gt;
        &lt;ul&gt;
           &lt;li&gt;&lt;a href='#'&gt;&lt;span&gt;Company Service Orders&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
           &lt;li class='last'&gt;&lt;a href='#'&gt;&lt;span&gt;Vendor Service Orders&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
     &lt;/li&gt;
     &lt;li class='last'&gt;&lt;a href='#'&gt;&lt;span&gt;Ad Hoc Report Builder&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  
  &lt;/div&gt;
  &lt;br&gt;
  &lt;form action="ServiceOReport.php" method="post"&gt;
  &lt;select name="ServiceOrders"&gt;
    &lt;option value="Network Error"&gt;Network Error&lt;/option&gt;
    &lt;option value="Reverse Rotation Detected"&gt;Computer Failure&lt;/option&gt;
    &lt;option value="Cover Off"&gt;Misc&lt;/option&gt;
    &lt;input type="text" name="sdate"id="datepicker" &gt;
    &lt;input type="submit" id ="refresh" value=" Submit "/&gt;&lt;br /&gt;
  &lt;/select&gt;
  &lt;/form&gt;
  
  &lt;div id="mydiv" class="grid_12 omega scroll"&gt;
  
  &lt;/div&gt;  
  
  &lt;div class="grid_12 "&gt;  
      &lt;div   id="TopBorder"  class="grid_12"&gt;
          &lt;footer class="mainFooter"&gt;
              &lt;p&gt;Copyright &amp;copy; 2014 &lt;a href="http://test.com"&gt;Test&lt;/a&gt;&lt;/p&gt;
          &lt;/footer&gt;
      &lt;/div&gt;
  &lt;/div&gt;  
  
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is my ServiceOReport.php page where I am taking the session variables and executing them in the query.</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;   
        &lt;link rel='stylesheet' type='text/css' href='styles.css' /&gt;
        &lt;link rel="stylesheet" href="grid.css" type="text/css" /&gt;
        &lt;link rel="stylesheet" href="backgroundcss.css" type="text/css" /&gt;
   &lt;/head&gt;      
  
    &lt;body  class="container"&gt;
          &lt;?php
   session_start();
  
          // Make a MySQL Connection
      mysql_connect("localhost", "****", "********") or die(mysql_error());
      mysql_select_db("Test_DB") or die(mysql_error());
  
      $ServiceOrders= $_SESSION["ServiceOrders"];
      $string=$_SESSION["date"];
      $timestamp = strtotime($string);
      $correctedDate = date("Y-m-d H:i:s", $timestamp);
  
      $result = mysql_query("Select EquipmentID,StreetNumber,StreetName,City,ZipCode,ZipPlusFour,CreatedDate,ServiceOrderdesc 
                              From CSS_ServiceOrders  
                              Where ServiceOrderdesc = '$ServiceOrders' and CreatedDate &gt; '$correctedDate'
                              order by CreatedDate,StreetName,StreetNumber;") 
      or die(mysql_error());  
  
      echo '&lt;table class="bordered"&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          &lt;th scope="col"&gt;EquipmentID&lt;/th&gt;
          &lt;th scope="col"&gt;ZipPlusFour&lt;/th&gt;        
          &lt;th scope="col"&gt;StreetNumber&lt;/th&gt;
          &lt;th scope="col"&gt;StreetName&lt;/th&gt;
          &lt;th scope="col"&gt;City&lt;/th&gt;       
          &lt;th scope="col"&gt;ZipCode&lt;/th&gt;                    
          &lt;th scope="col"&gt;CreatedDate&lt;/th&gt;
          &lt;th scope="col"&gt;ServiceOrderdesc&lt;/th&gt;   
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;';
  
  
      // keeps getting the next row until there are no more to get
      while($row = mysql_fetch_array( $result )) {
  
          echo "&lt;tr&gt;&lt;td&gt;"; 
          echo $row['EquipmentID'];
          echo "&lt;/td&gt;&lt;td&gt;"; 
          echo $row['ZipPlusFour'];
          echo "&lt;/td&gt;&lt;td&gt;";       
          echo $row['StreetNumber'];
          echo "&lt;/td&gt;&lt;td&gt;";       
          echo $row['StreetName'];
          echo "&lt;/td&gt;&lt;td&gt;";       
          echo $row['City'];
          echo "&lt;/td&gt;&lt;td&gt;";       
          echo $row['ZipCode'];
          echo "&lt;/td&gt;&lt;td&gt;";       
          echo $row['CreatedDate'];
          echo "&lt;/td&gt;&lt;td&gt;"; 
          echo $row['ServiceOrderdesc'];
          echo "&lt;/td&gt;&lt;/tr&gt;"; 
  
      } 
  
      echo "&lt;/tbody&gt;&lt;/table&gt;";
  ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>