$_post doesn't work on IIS 7

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Milind Chaavan
    New Member
    • Aug 2010
    • 2

    #1

    $_post doesn't work on IIS 7

    Hello,

    I am very new to PHP.

    However I am trying to deploy php website on IIS 7 (Windows Server 2008). But I am getting error :

    PHP Notice: Undefined index: count <file name> on line 77

    The problem is in $_POST['count'] array index, which found empty to IIS 7 or PHP (I don't know exactly)

    But If use @$_POST['count'] instead of $_POST['count'], the error get suppressed.

    I know in Apache we can define rules in httpd file, is there any way in IIS 7 / in PHP by which I don't have to change every page in whole website.

    Regards,
    Milind
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    When you get the "undefined index" warning, has there been any data sent via POST?

    If your code is generating this warning, it is usually because you fail to validate the input data properly. You should always make sure the data is actually there before using it. E.g:
    [code=php]<?php
    if(isset($_POST['stuff'])) {
    // Do things with $_POST['stuff']
    }
    ?>[/code]
    Or, if you want to use a default value if it is not set:
    [code=php]<?php
    ($stuff = @$_POST['stuff']) or $stuff = "default value";
    ?>[/code]

    You can of course just silence the warnings, but it doesn't fix anything. It just hides the problem from public view.

    You can do this either by adding either of these lines to the top of our PHP codes:
    [code=php]
    // Hide notices, but display errors
    error_reporting (E_ALL ^ E_NOTICE);
    // Hide all errors
    ini_set('displa y_errors', false);[/code]
    Or editing the following directives in your "php.ini" config file. (See the results of the phpinfo function for the location of that file.)
    Code:
    error_reporting = E_ALL ^ E_NOTICE
    display_errors = false

    Comment

    • Milind Chaavan
      New Member
      • Aug 2010
      • 2

      #3
      Thanks Atli ... it works :)

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        $_post doesn't work on IIS 7
        because it’s called $_POST

        Comment

        Working...