Value of $_POST variable is null, but shouldn't be.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • priston
    New Member
    • May 2007
    • 5

    Value of $_POST variable is null, but shouldn't be.

    hi everyone,
    [code=php]
    <?php
    $CompanyName=$_ POST['CompanyName'];
    echo $CompanyName;
    ?>[/code]

    [Please use CODE tags when posting your code. Thanks! --pbmods]

    I have been using this code to get values from forms.It was working fine.But lately it is not getting what has been entered in the field named CompanyName.
    It displays nothing.
    Last edited by pbmods; May 18 '07, 04:43 PM. Reason: Added code tags.
  • shidec
    New Member
    • May 2007
    • 26

    #2
    can u write down the form code?

    Comment

    • pbmods
      Recognized Expert Expert
      • Apr 2007
      • 5821

      #3
      Changed thread topic to better match contents.

      Is your form using POST or GET to send its contents? Try checking for:

      [CODE=PHP]
      echo "Get: $_GET[CompanyName]<br />";
      [/CODE]

      Comment

      • priston
        New Member
        • May 2007
        • 5

        #4
        I have tried both GET as well as POST method in my form.In both cases, it displayed nothing.The same code is working fine on my friends computer.But doesnt work on my computer.

        Comment

        • pbmods
          Recognized Expert Expert
          • Apr 2007
          • 5821

          #5
          Hm. Couple of things I would try.

          First thing, I would set error_reporting to E_ALL:
          [code=php]
          error_reporting (E_ALL);
          [/code]

          This will display NOTICE and STRICT errors that are normally turned off by default.

          Also, try this:
          [code=php]
          print_r($GLOBAL S);
          // Or...
          print('<pre>' . print_r($GLOBAL S, true) . '</pre>');
          [/code]

          This will output your entire $GLOBALS array, which includes $_GET, $_POST, etc. If your input made it to your script, it'll be in here somewhere.

          If not, take a look at this thread.

          Comment

          • srf
            New Member
            • May 2007
            • 1

            #6
            Getting an error when logging in

            Parse error: parse error, unexpected T_STRING in /home/content/a/z/r/azreff/html/login.php on line 18


            //Connect to database

            mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error() );
            mysql_select_db ($dbname) or die(mysql_error ());

            session_start() ;
            $username = $_POST['username'];
            $password = md5($_POST['password']);
            $query = “select * from users where username=’$user name’ and password=’$pass word’”;

            $result = mysql_query($qu ery);

            if (mysql_num_rows ($result) != 1) {
            $error = “Bad Login”;
            include “login.html”;

            } else {
            $_SESSION[‘username’] = “$username”;
            include “memberspage.ph p”;
            }

            ?>

            Comment

            • priston
              New Member
              • May 2007
              • 5

              #7
              As per your suggestion,I did error_reporting (E_ALL); and print_r($GLOBAL S),
              the array displayed the values passed on by the form.
              But it displayed warning:Undefin ed variable: _REQUEST and Use of undefined constant .

              Comment

              Working...