Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

[PHP] $_POST was empty due to syntax error

  • 01-09-2009 7:42am
    #1
    Registered Users, Registered Users 2 Posts: 4,475 ✭✭✭


    So last night I thought I'd install PHP5.2 on my WAMP server at home. Big mistake. 4 hours later I've wiped my server and reinstalled from WAMPServer2.0. Everything appears to be ok except my main login form wouldn't post or get data:
    <?php
    error_reporting(E_ALL);
    
    echo "<pre>";
    $data = file_get_contents('php://input');
    var_dump($data);
    print_r($_REQUEST);
    print_r($_POST);
    print_r( $GLOBALS );
    print_r( $HTTP_GET_VARS );
    print_r( $HTTP_POST_VARS );
    echo "</pre>";
    ?>
    
    When I ran this and posted the form I'd get:
    string(0) ""
    Array()
    Array()
    Array
    (
    [GLOBALS] => Array
    *RECURSION*
    [_POST] => Array
    (
    )

    [_GET] => Array
    (
    )

    [_COOKIE] => Array
    (
    [logged_in] => 1
    [PHPSESSID] => lrl9o34cc5p3u3fmd1dl502s51
    )

    [_FILES] => Array
    (
    )

    [_REQUEST] => Array
    (
    )

    [error] =>
    [lemail] =>
    [lpass] =>
    [lrem] => 0
    [data] =>
    )

    Notice: Undefined variable: HTTP_GET_VARS in C:\wamp\www\eazine\ver2\login.php on line 15

    Notice: Undefined variable: HTTP_POST_VARS in C:\wamp\www\eazine\ver2\login.php on line 16
    Reducing the form and checking all syntax, I found that the form itself was in a showform() function which took in 2 parameters, but on the initial call, I only had one, showform(""). Changing it to showform("", "") resolved the issue.

    Any reason why a) the form would still show and error_reporting wouldn't catch it? b) the resulting post would be empty? It had me googling for about a hour and a half before I figured it out.


Comments

  • Registered Users, Registered Users 2 Posts: 4,475 ✭✭✭corblimey


    I tell a lie, I still have this problem. I was able to get in once, but not anymore. $_POST is constantly empty.


  • Registered Users, Registered Users 2 Posts: 6,570 ✭✭✭daymobrew


    Post the form html code.


  • Registered Users, Registered Users 2 Posts: 4,475 ✭✭✭corblimey


    daymobrew wrote: »
    Post the form html code.

    After a few more attempts, I took the form html code out of the function I had it in, and it seems to be work fine now. Not sure why that works, but why it worked pre-PHP5.2 or WAMPServer2.0. If forms won't work in functions, I'm in a lot of trouble :p

    ETA: Ignore all my rambling above. It turned out that it was posting but on the next page I redirect back to login if a login cookie isn't set. However I was using HTTP_COOKIE_VARS instead of _COOKIE and this was always unset, so it would always redirect back to the login page with an empty _REQUEST. Simple.


Advertisement