Title: Parsing vars using $_POST
Last modified: August 19, 2016

---

# Parsing vars using $_POST

 *  [very_badpritt](https://wordpress.org/support/users/very_badpritt/)
 * (@very_badpritt)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/parsing-vars-using-_post/)
 * I am trying to pars a var with a form redirect to itself and retrieve it by using‘`'
   $_POST[ID]'`‘ in a if construction and then do something like print().
 * But somehow my var ID is always empty!?
 * It works outside WP so the code is correct.
 * I believe it has something to do with the register_global but this is out of 
   my league 🙁 Also I looked at this codex [David House](http://codex.wordpress.org/User:DavidHouse/Wordpress_Code_Flow#Request_Parsing)
   but this is to complicated for me too. And I could not get the url-redirect-plugin
   to work from Imthiaz ([).](http://imthi.com/blog/programming/wordpress-url-rewrite-hack-plugin.php#comment-18544)
 * I use RunPHP in my WP 2.5.1 and I host the WP on my own server (so lots af access
   permisons) 😉
 * Can someone tell me how to retrieve a var parsed through a form? I would be so
   great full, thanks a lot in advance!

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/parsing-vars-using-_post/#post-799036)
 * Pasting the exact code here would be more helpful.
 *  Thread Starter [very_badpritt](https://wordpress.org/support/users/very_badpritt/)
 * (@very_badpritt)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/parsing-vars-using-_post/#post-799147)
 * Okay, sorry about that 😉 Here is the code:
 * ‘`'
    <?php include_once($_SERVER['DOCUMENT_ROOT']."/incl/db_connection.php");
 * if (!$_POST['ID']) {
    //pull down menu with names from tablename print("<form
   name=\"check_dob\" action=\"/to itself/\" method=\"post\" enctype=\"multipart/
   form-data\">"); print("<select>"); print("<option value=\"\">Pick a name</option
   >"); //collect data and sort by name $sqlResult = mysql_query("SELECT * FROM 
   tablename WHERE poule = '1B' ORDER BY name") or die ("Database error, please 
   try again. (" . mysql_error() . ")");
 *  while($sqlRow = mysql_fetch_array($sqlResult)) { //begin while
    print("<option
   name=\"ID\" value=\"".$sqlRow['ID']."\">".$sqlRow['name']." (".$sqlRow['team'].")
   </option>"); }//end while print("</select>"); print(" <input type=\"submit\" 
   value=\"Hit it\">"); print("</form>
 * ");
    } else if ($_POST['ID']) { //collect data by $_GET[ID] $sqlResult = mysql_query("
   SELECT * FROM tablename WHERE ID='".$_POST['ID']."' LIMIT 1") or die ("Database
   error, please try again. (" . mysql_error() . ")"); $sqlRow = mysql_fetch_array(
   $sqlResult);
 * //print personal data
    print("<b>".$sqlRow['name']."</b> with nr (".$sqlRow['
   tdvnr'].") from <b>".$sqlRow['team']."</b> in <b>".$sqlRow['poule']."</b> is 
   celebrating his birthday on <b>".$sqlRow['dob']."-".$sqlRow['dob_yr']."</b>
 * ");
    } ?> '‘
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [17 years, 10 months ago](https://wordpress.org/support/topic/parsing-vars-using-_post/#post-799150)
 *     ```
       <select>
       ...
       <option name=\"ID\" value=\"".$sqlRow['ID']."\">"
       ...
       ```
   
 * That’s wrong. The select should have the name, the options only have the values.
   Like this:
 *     ```
       <select name='ID'>
       <option value='whatever'>Something</option>
       <option value='whatever2'>Something else</option>
       ...
       </select>
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Parsing vars using $_POST’ is closed to new replies.

## Tags

 * [redirect](https://wordpress.org/support/topic-tag/redirect/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * Last activity: [17 years, 10 months ago](https://wordpress.org/support/topic/parsing-vars-using-_post/#post-799150)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
