title: How to pass dynamically created input values through POST variables
body: <p>I will be brief.<br>
  I have this:  </p>
  
  <p>functions.php</p>
  
  <pre><code>function consulta($sql){
      $consulta = mysql_query($sql, $GLOBALS['conexion']) or die (mysql_error());
  
      if(mysql_num_rows($consulta) == 0){
          return -1;
      }else if (mysql_num_rows($consulta) == 1){
          $fila = mysql_fetch_array($consulta);
          return $fila;
      }else{
          while($fila = mysql_fetch_array($consulta)){
              $lista[] = $fila;
          }
          return $lista;
      }
  }
  </code></pre>
  
  <p>formgenerator.php  </p>
  
  <pre><code>$art_ptes = consulta("SELECT * FROM articulos WHERE autorizacion = '0'");
  echo "&lt;form action='../private/control_insercion.php' method='POST'&gt;";
  echo "&lt;input type='hidden' name='es_autorizacion' value='ok' /&gt;";
  echo "&lt;table id='aut_ptes'&gt; 
      &lt;tr&gt;&lt;th colspan='8'&gt;Autorizaciones pendientes&lt;/th&gt;&lt;/tr&gt;
      &lt;tr&gt;&lt;th&gt;Fecha&lt;/th&gt;&lt;th&gt;Título&lt;/th&gt;&lt;th&gt;Categoría&lt;/th&gt;&lt;th&gt;Artículo&lt;/th&gt;     &lt;th&gt;Autor&lt;/th&gt;&lt;th colspan='3'&gt;Sanción&lt;/th&gt;&lt;/tr&gt;";
  if($art_ptes !== -1){
      if(is_array($art_ptes[0])){
          for ($i = 0 ; $i &lt; count($art_ptes) ; $i++) {
              echo "&lt;tr&gt;&lt;td&gt;".$art_ptes[$i][1]."&lt;/td&gt; &lt;td&gt;".$art_ptes[$i][2]."&lt;/td&gt;&lt;td&gt;".$art_ptes[$i][3]."&lt;/td&gt;&lt;td&gt;".substr($art_ptes[$i][4], 0, 140)."&lt;a href='#'&gt;...ver&lt;/a&gt;&lt;/td&gt;&lt;td&gt;".$art_ptes[$i][5]."&lt;/td&gt;&lt;td&gt;AUT: &lt;input name='autorizar".$i."' value='aut' type='radio' /&gt;&lt;/td&gt;&lt;td&gt;DEN: &lt;input name='autorizar".$i."' value='den' type='radio' /&gt;&lt;/td&gt;&lt;td&gt;PTE: &lt;input name='autorizar".$i."' value='pte' type='radio' checked='checked'/&gt;&lt;/td&gt;&lt;/tr&gt;";
              echo "&lt;input type='hidden' name='id".$i."' value='".$art_ptes[$i][0]."' /&gt;";
              echo "&lt;input type='hidden' name='titulo".$i."' value='".$art_ptes[$i][2]."' /&gt;";
              echo "&lt;input type='hidden' name='autor".$i."' value='".$art_ptes[$i][5]."' /&gt;";
          }
          echo "&lt;tr&gt;&lt;td colspan='8'&gt;&lt;input type='submit' value='Enviar!' /&gt;&lt;/td&gt;&lt;/tr&gt;";
      } else {
          echo "&lt;tr&gt;&lt;td&gt;".$art_ptes[1]."&lt;/td&gt;&lt;td&gt;".$art_ptes[2]."&lt;/td&gt;&lt;td&gt;".$art_ptes[3]."&lt;/td&gt;&lt;td&gt;".substr($art_ptes[4], 0, 140)."&lt;a href='#'&gt;...ver&lt;/a&gt;&lt;/td&gt;&lt;/td&gt;&lt;td&gt;".$art_ptes[5]."&lt;/td&gt;&lt;td&gt;AUT: &lt;input name='autorizar' value='aut' type='radio' /&gt;&lt;/td&gt;&lt;td&gt;DEN: &lt;input name='autorizar' value='den' type='radio' /&gt;&lt;/td&gt;&lt;td&gt;PTE: &lt;input name='autorizar' value='pte' type='radio' checked='checked'/&gt;&lt;/td&gt;&lt;/tr&gt;";
          echo "&lt;input type='hidden' name='id' value='".$art_ptes[0]."' /&gt;";
          echo "&lt;input type='hidden' name='titulo' value='".$art_ptes[2]."' /&gt;";
          echo "&lt;input type='hidden' name='autor' value='".$art_ptes[5]."' /&gt;";
          echo "&lt;tr&gt;&lt;td colspan='8'&gt;&lt;input type='submit' value='Enviar!' /&gt;&lt;/td&gt;&lt;/tr&gt;";
      }
  } else {
      echo "&lt;tr&gt;&lt;td colspan='8'&gt;SIN REGISTROS&lt;/td&gt;&lt;/tr&gt;";
  }
  echo "&lt;/table&gt;
  
      &lt;/form&gt;";
  </code></pre>
  
  <p>control_insercion.php  </p>
  
  <pre><code>/* ...more irrelevant code precedes */
  } else if (isset($_POST['es_autorizacion']) and $_POST['es_autorizacion'] == 'ok') {
  
      $emails_den = array();
      $emails_aut = array();
  
      if(!isset($_POST['autorizar'])){
          $i = 0;
          while(isset($_POST['autorizar'.$i]) and $_POST['autorizar'.$i] == 'aut'){
  
              if($_POST['autorizar'.$i] == 'aut') {
                  $consulta = ("UPDATE articulos SET autorizacion = '1' WHERE titulo = '".$_POST['titulo'.$i]."' AND autor = '".$_POST['autor'.$i]."' AND id = '".$_POST['id'.$i]."';"); 
                  $resultado = mysql_query($consulta, $conexion) or die(mysql_error());
                  $email = consulta("SELECT email FROM autores WHERE autor = '".$_POST['autor'.$i]."';");
                  $emails_aut[] = $email;
  
              }else if($_POST['autorizar'.$i] == 'den') {
                  $consulta = ("DELETE FROM articulos WHERE id = '".$_POST['id'.$i]."';");
                  $resultado = mysql_query($consulta, $conexion) or die(mysql_error());
                  $email = consulta("SELECT email FROM autores WHERE autor = '".$_POST['autor'.$i]."';");
                  $emails_den[] = $email;
              }
              $i++;
          }
      } else {
          if($_POST['autorizar'] == 'aut') {
                  $consulta = ("UPDATE articulos SET autorizacion = '1' WHERE titulo = '".$_POST['titulo']."' AND autor = '".$_POST['autor']."' AND id = '".$_POST['id']."';"); 
                  $resultado = mysql_query($consulta, $conexion) or die(mysql_error());
                  $email = consulta("SELECT email FROM autores WHERE autor = '".$_POST['autor']."'");
                  $emails_aut[] = $email;
  
              } else if ($_POST['autorizar'] == 'den') {
                  $consulta = ("DELETE FROM articulos WHERE id = '".$_POST['id']."';");
                  $resultado = mysql_query($consulta, $conexion) or die(mysql_error());
                  $email = consulta("SELECT email FROM autores WHERE autor = '".$_POST['autor']."';");
                  $emails_den[] = $email;
              }
  
      }
      $uno = serialize($emails_den); //checking whther everything went right//
      $dos = serialize($emails_aut);
      header("location../public/pruebas.php?resultado=".$uno."&amp;resultado2=".$dos."");
  }
  </code></pre>
  
  <p>It consists is consulting the users articles that are waiting for the administrator authorization.</p>
  
  <p>In formgenerator.php a dynamic table is generated with all these articles.  </p>
  
  <p>The administrator click on authorized or denied at each article row.  </p>
  
  <p>POST variables pass to the processor php page where the articles should be aupdated to authirized or deleted in the corresponding mysql table.  </p>
  
  <p>I ask for some help as the final result of all these scripts is that it returns the control_insercion.php page blank. Even the header is not executed.</p>
  
  <p>I would appreciate any help!</p>