• Resolved santon

    (@santon)


    Hello.

    I have installed EXEC-PHP plugin which allows me to put PHP scripts into my pages. I created a simple page with the following content:

    <?php
    echo '<pre>';
    print_r($_POST);
    echo '</pre>';
    ?>
    <form method="post">
    <input type="text" name="name"/>
    <input type="submit"/>
    </form>

    When I open this page, it’s works as intended, showing me the following text:

    Array
    (
    )

    and the input form.

    When I press the “Submit” button with empty text input field, I get the following:

    Array
    (
        [name] =>
    )

    Everything is still excellent. But when I enter some text to the input field and press “Submit”, I’m getting “Sorry, but you are looking for something that isn’t here.”

    How to fix this? Where in the WordPress’s code the checking of POST data presence is performed??

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter santon

    (@santon)

    I have solved it. The problem is that “name” is a reserved name for WP internal usage. I just changed the name to ABCDEF, and everything is fine:

    <?php
    echo '<pre>';
    print_r($_POST);
    echo '</pre>';
    ?>
    <form method="post">
    <input type="text" name="ABCDEF"/>
    <input type="submit" />
    </form>

    SAnton:

    Man! I don’t know how you figured this out, but I am eternally greatful. I have been fiddling with this for the past week trying to figure out what wordpress was doing with a post vice a get and could not figure it out.

    I was experimenting with a simple form to see how it works with a page template and it just so happens that I too had a name=”name” on an input tag. Changed it to name=”fullname” and it works like a charm.

    Thanks for your insight…

    Warren

    it’d be great if there were a list of reserved variable names to avoid. does one already exist?

    SAnton: Rock on, dude! I’ve also been wrastlin’ with this – good catch!

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Hah. Yes.

    It’s always a good programming practice to pick unique names for variables. This is not specific to WordPress, but I tend to name things that are submitted something like pluginname_variablename. This ensures that they’ll be there, ignoring wild coincidence. 🙂

    hey santon..awesome dude..thanks a lot for helping us out here..awesome awesome yoyoyoyoyo..thanks

    You should also take the ‘action=…’ part out of the form tag if you have one in your form. Your post helped be on this but only wish I found it a few hours earlier.

    thanks,
    Jonathan

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to process data acquired by POST method?’ is closed to new replies.