php4.3.2 can't get POST to work.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Acteon

    php4.3.2 can't get POST to work.

    Hello,

    I've installed php4.3.2 on my Redhat 8.0 box along with Apache2.046.
    I'm trying to teach myself some php using Larry Ullman's book "PHP for
    the World Wide Web".

    There's one example I typed just as it appears in the book but it
    dosen't work. I was wondering if there was some setting that needs to
    be set in the php config for it to work.

    The script is a simple html script, which calls a php script passing
    it the variables which it got by the forms:

    #########HTML SCRIPT######### ##########
    <html>
    <head>
    <title>HTML Form</title>
    </head>
    <body>
    <form ACTION="HandleF orm.php" METHOD=POST>
    First Name<input TYPE=TEXT NAME="FirstName " SIZE=20><br>
    Last Name <input TYPE=TEXT NAME="LastName" SIZE=20><br>
    E-mail Address <input TYPE=TEXT NAME="Email" SIZE=60><br>
    Comments <textarea NAME="Comments" ROWS=5 COLS=40></textarea><br>
    <input TYPE=SUBMIT NAME="SUBMIT" VALUE="Submit!" >
    </form>

    </body>
    </html>

    ##############P HP SCRIPT "HandleForm.php "############## #######
    <HTML>
    <HEAD>
    <TITLE>Form Results</title>
    <BODY>
    <?php
    /* This page receives and handles the data generated by "form.html" .
    */
    print "Your first name is $FirstName.<BR> \n";
    print "Your last name is $LastName.<BR>\ n";
    print "Your E-mail is $Email.<BR>\n";
    print "This is what you had to say:<BR>\n$Comm ents<BR>\n";
    ?>
    </BODY>
    </HTML>

    ####
    This is the output:


    Your first name is .
    Your last name is .
    Your E-mail is .
    This is what you had to say:


    All the variables are apparently empty. I've also tried with the GET
    method. Any idea of what could be wrong in either my script or php
    settings ?

    Acteon
  • Richard Hockey

    #2
    Re: php4.3.2 can't get POST to work.

    As the other fellow said, do a search for register_global s.

    Try using $_POST["myvariable "] and $_GET["myvariable "] to read from
    variables, instead of $myvariable. (where myvariable is the name of an
    object in the submitted form).

    "Acteon" <acteon@yahoo.c om> wrote in message
    news:bec6f345.0 307081715.4c148 e3c@posting.goo gle.com...[color=blue]
    > Hello,
    >
    > I've installed php4.3.2 on my Redhat 8.0 box along with Apache2.046.
    > I'm trying to teach myself some php using Larry Ullman's book "PHP for
    > the World Wide Web".
    >
    > There's one example I typed just as it appears in the book but it
    > dosen't work. I was wondering if there was some setting that needs to
    > be set in the php config for it to work.
    >
    > The script is a simple html script, which calls a php script passing
    > it the variables which it got by the forms:
    >
    > #########HTML SCRIPT######### ##########
    > <html>
    > <head>
    > <title>HTML Form</title>
    > </head>
    > <body>
    > <form ACTION="HandleF orm.php" METHOD=POST>
    > First Name<input TYPE=TEXT NAME="FirstName " SIZE=20><br>
    > Last Name <input TYPE=TEXT NAME="LastName" SIZE=20><br>
    > E-mail Address <input TYPE=TEXT NAME="Email" SIZE=60><br>
    > Comments <textarea NAME="Comments" ROWS=5 COLS=40></textarea><br>
    > <input TYPE=SUBMIT NAME="SUBMIT" VALUE="Submit!" >
    > </form>
    >
    > </body>
    > </html>
    >
    > ##############P HP SCRIPT "HandleForm.php "############## #######
    > <HTML>
    > <HEAD>
    > <TITLE>Form Results</title>
    > <BODY>
    > <?php
    > /* This page receives and handles the data generated by "form.html" .
    > */
    > print "Your first name is $FirstName.<BR> \n";[/color]

    print "Your first name is $_POST["FirstName"].<BR>\n";
    [color=blue]
    > print "Your last name is $LastName.<BR>\ n";[/color]

    print "Your last name is $_POST["LastName"].<BR>\n";
    [color=blue]
    > print "Your E-mail is $Email.<BR>\n";[/color]

    print "Your E-mail is $_POST["Email"].<BR>\n";
    [color=blue]
    > print "This is what you had to say:<BR>\n$Comm ents<BR>\n";[/color]

    print "This is what you had to say:<BR>\n$_POS T["Comments"]<BR>\n";
    [color=blue]
    > ?>
    > </BODY>
    > </HTML>
    >
    > ####
    > This is the output:
    >
    >
    > Your first name is .
    > Your last name is .
    > Your E-mail is .
    > This is what you had to say:
    >
    >
    > All the variables are apparently empty. I've also tried with the GET
    > method. Any idea of what could be wrong in either my script or php
    > settings ?
    >
    > Acteon[/color]


    Comment

    • Acteon

      #3
      Re: php4.3.2 can't get POST to work.

      "Richard Hockey" <richardhockey@ dsl.pipex.com> wrote in message news:<3f0bccef$ 0$15035$cc9e4d1 f@news.dial.pip ex.com>...[color=blue]
      > As the other fellow said, do a search for register_global s.
      >
      > Try using $_POST["myvariable "] and $_GET["myvariable "] to read from
      > variables, instead of $myvariable. (where myvariable is the name of an
      > object in the submitted form).[/color]

      Thank you, that solved the problem. I ended up declaring my variables
      on top:

      $FirstName = $_POST["FirstName"];
      $LastName = $_POST["LastName"];

      and so on.

      This way If I need to use the variable more then once I won't need to
      keep typing $_POST["varname"]. Is that how php coders usually do it ?

      Comment

      Working...