ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How to access $_POST?

August 24, 2010 4:27pm

Subscribe [3]
  • #1 / Aug 24, 2010 4:27pm

    siffring

    147 posts

    I have a manually create form on one template that posts to a second template. The second template is set to PHP parse on input, but doesn’t see any $_POST parameters.

    Here is the form:

    <form action="/signup/step2" method="POST">
      Email: <input type="text" class="text" name="email" class="input" size="25" />
      <input type="submit" class="button" value="Sign Up" /></p>
    </form>

    In the signup/step2 template, I have tried all of these to no avail.

    <?php
    echo $_POST['email'];
    echo $_REQUEST['email'];
    
    global $IN;
    print_r($IN->GBL('email','POST'));
    ?>

    I also tried {exp:parameters:get name="email"} using the GET/POST parameters plugin.

    All of these return an empty string.

    I printed a phpinfo() on my step2 template and noticed that there was a _REQUEST[”/signup/step2/”] variable set, but no _REQUEST[“email”] variable.

    Is it normal for PHP to see templates/template groups as _REQUEST variables of index.php?

    I’m on MediaTemple DV if it matters. I’m leaning towards this being a PHP config issue, but am not sure what needs to be tweaked.

    Any thoughts?

  • #2 / Aug 24, 2010 10:18pm

    siffring

    147 posts

    To further isolate the issue, I used the same form to post to a php file outside of EE. The php file was able to echo $_POST[‘email’].

    So, this tells me that the form is posting and that PHP on the server is capable of reading POST variables.

    Any idea on why I can’t read the POST variable inside an EE template?

  • #3 / Aug 25, 2010 9:51am

    Robin Sowell

    13255 posts

    Any chance you’re doing some rewriting?  Check your headers- are you going directly to the post page.  It worked fine for me in a quick test- and I can’t think why it normally wouldn’t.

  • #4 / Aug 25, 2010 12:26pm

    siffring

    147 posts

    Bingo. A mod_rewrite broke it for some reason.

    Here is the offending rewrite.

    # Add a trailing slash to paths without an extension
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
    RewriteRule ^(.*)$ $1/ [L,R=301]

    Thanks for the help!

  • #5 / Aug 25, 2010 12:33pm

    Sue Crocker

    26054 posts

    Glad Robin was able to help. Don’t hesitate to post again as needed.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases