title: How to get the value of html <input type="hidden"> in PHP?
body: <p>I am a certifid newbie so pls be patient with me if my question might sound very idiotic to you.</p>
  
  <p>Hi guys. Im trying to get the value of an html <code>&lt;input type="hidden"&gt;</code> using PHP. The value of that hidden element is passed from Javascript and I need to display the value of that hidden element by using php echo. From what I understand (I hope I understood it right) when you do something like <code>$description = isset($_GET['description']) ? $_GET['description'] : null;</code> and also <code>&lt;input type="hidden" id="description" value="&lt;?php echo $description; ?&gt;" /&gt;</code> you can access/display the value of the hidden element by using <code>&lt;?php echo $_GET['description']; ?&gt;</code> but I am getting an undefined index: description. I am a total noob so I am really confused about this. I hope my question is not that confusing. Anyway I am very willing to answer probing questions. </p>
  
  <p>BTW, here are the codes:</p>
  
  <p><b><code>index.php</code></b></p>
  
  <pre><code>&lt;?php include('functions.php'); ?&gt;
  
  &lt;?php 
   $yr = isset($_GET['year_list']) ? $_GET['year_list'] : null;
   $evnt = isset($_GET['event_list']) ? $_GET['event_list'] : null; 
   $description = isset($_GET['description']) ? $_GET['description'] : null; 
  ?&gt;
  
  &lt;html&gt;
  &lt;head&gt;
   &lt;script type="text/javascript" src="myscripts.js"&gt;&lt;/script&gt;
   &lt;style type='text/css'&gt;
    #show_description {
     min-height: 100px;
     min-width: 500px;
     max-height: 100px;
     max-width: 500px;
     background-color: #000;
     color: #fff;
     padding: 10px;
    }
   &lt;/style&gt;
  &lt;/head&gt;
  &lt;body onload="check_year_event();"&gt;
   &lt;div&gt;
    &lt;form name="myform" action="index.php" method="get" &gt;
     &lt;input type="hidden" id="hidden_year_list" value="&lt;?php echo $yr; ?&gt;" /&gt;
     &lt;input type="hidden" id="hidden_event_list" value="&lt;?php echo $evnt; ?&gt;" /&gt;
     &lt;input type="hidden" id="description" value="&lt;?php echo $description; ?&gt;" /&gt;
  
     Select Year: &lt;?php echo hspacer(1); ?&gt;
     &lt;select id="year_list" name="year_list" onchange="check_year_event();" &gt;
     &lt;?php  
      for($year = (date('Y') - 100); $year &lt;= (date('Y') + 100); $year++ ) {
       if ($year == date('Y'))  echo "&lt;option value='$year' name='$year' selected='' &gt;" . $year . "&lt;/option&gt;";
       else echo "&lt;option value='$year' name='$year' &gt;" . $year . "&lt;/option&gt;";
      }
     ?&gt;
     &lt;/select&gt;
     &lt;?php echo hspacer(5); ?&gt;
     Select Event:  &lt;?php echo hspacer(1); ?&gt;
     &lt;select id="event_list" name="event_list" onchange="check_year_event();" &gt;
     &lt;?php  
      $events = array("Karate Tournament", "Beauty Pageant", "Film Festival", "Singing Contest", "Wedding");
  
      foreach($events as $event) echo "&lt;option value='$event' name='$event' &gt;" . $event . "&lt;/option&gt;";
     ?&gt;
     &lt;/select&gt;
     &lt;?php echo vspacer(2); echo hspacer(22); ?&gt;
     &lt;input type="submit" id="send_notice" value="Send Notice" onclick="check_year_event(); return false; "/&gt; 
    &lt;/form&gt;
   &lt;/div&gt;
  
   &lt;div id="show_description" &gt;
    &lt;?php echo $_GET['description']; ?&gt;
   &lt;/div&gt;
  
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><b><code>functions.php</code></b></p>
  
  <pre><code>&lt;?php
   function hspacer($num_of_spaces) {
    $spaces = "";
    if ($num_of_spaces &gt; 0)  for($i=0; $i&lt;$num_of_spaces; $i++ )  $spaces .= "&amp;nbsp;";
  
    return $spaces;
   }
  
   function vspacer($num_of_linefeeds) {
    $linefeeds = "";
    if ($num_of_linefeeds &gt; 0)  for($i=0; $i&lt;$num_of_linefeeds; $i++ )  $linefeeds .= "&lt;br /&gt;";
  
    return $linefeeds;
   }
  ?&gt;
  </code></pre>
  
  <p><b><code>myscripts.js</code></b></p>
  
  <pre><code>function create2DArray(row, col){
   var array2D = new Array(row);
  
   for (var i = 0; i &lt; row; i++) {
    array2D[i] = new Array(col);
   }
  
   return array2D;
  }
  
  
  function check_year_event() {
   var years_and_events = create2DArray(10, 3);
  
  
   years_and_events[0][0] = 2001; 
   years_and_events[0][1] = "Karate Tournament"; 
   years_and_events[0][2] = "Annual karate tournament held globally"; 
   years_and_events[1][0] = 2002; 
   years_and_events[1][1] = "Beauty Pageant"; 
   years_and_events[1][2] = "Beauty pageant held globally"; 
   years_and_events[2][0] = 2003; 
   years_and_events[2][1] = "Film Festival"; 
   years_and_events[2][2] = "Film festival held globally"; 
   years_and_events[3][0] = 2004; 
   years_and_events[3][1] = "Singing Contest"; 
   years_and_events[3][2] = "Singing contest tournament held globally"; 
   years_and_events[4][0] = 2005; 
   years_and_events[4][1] = "Wedding"; 
   years_and_events[4][2] = "Wedding tournament held globally"; 
   years_and_events[5][0] = 2007; 
   years_and_events[5][1] = "Karate Tournament"; 
   years_and_events[5][2] = "Annual karate tournament held globally"; 
   years_and_events[6][0] = 2008; 
   years_and_events[6][1] = "Beaty Pageant"; 
   years_and_events[6][2] = "Beauty pageant held globally"; 
   years_and_events[7][0] = 2009; 
   years_and_events[7][1] = "Film Festival"; 
   years_and_events[7][2] = "Film festival held globally"; 
   years_and_events[8][0] = 2010; 
   years_and_events[8][1] = "Singing Contest"; 
   years_and_events[8][2] = "Singing contest tournament held globally"; 
   years_and_events[9][0] = 2011; 
   years_and_events[9][1] = "Wedding"; 
   years_and_events[9][2] = "Wedding tournament held globally"; 
  
  
   var year = document.getElementById('year_list').value;
   var event = document.getElementById('event_list').value;
   var found = false;
  
   for (var i = 0; i &lt; years_and_events.length; i++) {
    if ((year == years_and_events[i][0]) &amp;&amp; (event == years_and_events[i][1])) {
      document.getElementById('description').value = years_and_events[i][2];
      document.getElementById('send_notice').style.visibility = "hidden";
      document.getElementById('show_description').style.visibility = "visible";
      found = true;
      break;
     }
    }
  
   if (found == false) {
    document.getElementById('show_description').style.visibility = "hidden";
    document.getElementById('send_notice').style.visibility = "visible";
   }
  }
  </code></pre>