Results 1 to 8 of 8

Thread: post request parameters are lost

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    Slovenia
    Posts
    40

    post request parameters are lost

    I'm using Apache 1.3.12 and php 4.2.2 on win2k! Php webpages
    works fine, only post-request parameters are lost when I call new php page.
    example:
    I have html file:
    **********************************
    <html>
    <head>
    </head>
    <body>
    <form action="my_first.php" method="post"><br>
    Name: <input type=text name="name"><br>
    <input type=submit value="Go">
    </form>
    </body>
    </html>
    **********************************
    my_first.php
    **********************************
    <html>
    <head>
    </head>
    <body>
    <?php
    echo "Hello " .$name;
    ?>
    </body>
    </html>
    **********************************
    If I write something into Name field and click 'Go', only 'Hello '
    is displayed on the next page - .$name has null value.

    Can somebody help me? Is there something wrong with Apache
    configuration?

    Tomaz

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    PHP Code:
    <?php 
    global $name;

    echo 
    "Hello " .$name
    ?>

    Now?

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    Slovenia
    Posts
    40
    Stil doesn't work!
    Tomaz

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Code:
    echo "Hello, " . $_POST['name'] . "!";
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    don't use global mendhak, it is deprecated. what hobo suggested is the answer and is another feature

    what is happing is that register_globals is OFF for secruity reasons in the php.ini file and the only way to access variables sent form one page to the other is by the means of the Super Globals.

    $_GET, $_POST, $_REQUEST, $_SESSION, $_FILES

    those ar ethe super globals. you can find out more in the php manual at www.php.net

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    I see, thanks phpman.

    Now I'll have to change all the files I made using global.

  7. #7

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    Slovenia
    Posts
    40
    I set register_global to "On" in php.ini file and now it works fine.
    Thank's for help to all of you!

    Tomaz

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Originally posted by tompod
    I set register_global to "On" in php.ini file and now it works fine.
    Thank's for help to all of you!

    Tomaz
    phpman just pointed out that it would pose a security risk if you keep it on. Why not do Hobo's way?

    PHP Code:
    $_POST['name'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width