• 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 but this is to complicated for me too. And I could not get the url-redirect-plugin to work from Imthiaz ().

    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)
  • Pasting the exact code here would be more helpful.

    Thread Starter very_badpritt

    (@very_badpritt)

    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)

    (@otto42)

    www.remarpro.com Admin

    <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.