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.

No $_POST data in template

September 01, 2011 9:09am

Subscribe [5]
  • #1 / Sep 01, 2011 9:09am

    StudioKong

    34 posts

    Something basic: I am trying to pass some information from a form to another page.

    My form:

    <form id="login_form" action="{path=user/loginrespons}" method="post">
      <fieldset>
        <label for="firstname">Email address<abbr title="Required field">*</abbr></label> <input type="text" class="required email" name="email" />
    
       <input type="submit" class="input_submit" name="submit" value="Submit" />
      </fieldset>
     </form>

    My “loginrespons” template:

    <?php 
    
        if ( ! isset($_POST['email'])) {
    
                $email = FALSE;
    
        }else{
    
                $email = $_POST['email'];
        }
        
     ?>

    php is enabled for this template, but no data is passed. When I put my response page outside of EE as a regular php page everything works fine.
    Any idea what I am missing here?

  • #2 / Sep 09, 2011 6:14pm

    LMO

    203 posts

    You can try using the codeigniter post variables.

    You need to make sure you reference the EE super object and then use the CI input library to get the post variables.

  • #3 / Sep 15, 2011 7:11pm

    Maybe you can start with a vardump. <?php var_dump($_POST); ?>. to see if anything comes through.

  • #4 / Sep 19, 2011 7:23pm

    StudioKong

    34 posts

    Thank you both for having a look.

    I noticed a 405 Method Not Allowed error in Firebug, although php is enabled (the rest of this page’s php was working fine). I just deleted the template in the template manager, made a new one with same settings and code an now everything works fine…

  • #5 / Oct 01, 2011 5:44am

    Famous Quotes

    1 posts

    Simply use the following code to check what values are being passed via post method.

    <?php print_r($_POST); exit; ?>

  • #6 / Oct 28, 2011 1:10pm

    vosSavant

    380 posts

    I had the same problem with normal $_POST[‘something’] not showing anything (I got an undefined index notice).

    The CI syntax below worked for me:

    $something = $this->EE->input->post('something');
  • #7 / Jul 23, 2012 4:45am

    Adam Christianson

    115 posts

    I’m having this exact issue under EE 2.4.0 and I can;t seem to get my form working. I noticed when I check the headers that I see the POST data, but the status code shows 301:

    [code
    Request Method:POST
    Status Code:301 Moved Permanently
    </code></pre>I have tried dumping both the $_POST var and the $this->EE->input->post value and get NULL results for both.

    [code]
    print_r($_POST);
    var_dump($this->EE->input->post(‘email’));</code></pre>

    Like StudioKong mentioned if I post to a PHP page outside the EE the data comes across fine. I did try creating a new template from scratch inside the EE Template Manager, but I still ended up with no POST data on submit.

    Any clues?

  • #8 / Jul 23, 2012 4:01pm

    Adam Christianson

    115 posts

    I may have solved my own issue on this one. My Comment forms weren’t posting either and a friend pointed out that my be my HTACCESS rule for removing the index.php and these Posts not adding back in the trailing slash.

    Details can be found here: http://ellislab.com/forums/viewthread/217896/#1007317

    It fixed my comment form and I’m going to try these pages now, but the 301 Redirect I was seeing seems to support the theory.

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

ExpressionEngine News!

#eecms, #events, #releases