i can't seem to pass values with php

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

    i can't seem to pass values with php

    I am trying to study php from a book. But the code doesn't seem to
    work for me. I set up a form, as follows:

    <html>
    <head>
    <title>form</title>
    </head>
    <body>
    <form action="results .php" method="GET">
    <p>Name: <input type="text" name="name">
    <P>
    <input type="submit" name="Submit">
    <input type="Reset"></form>
    </body>
    </html>

    Then I wrote some code for a processing file titled "results.ph p" as
    instructed:

    <head>
    <title>form results</title>
    </head>
    <body>
    <?php
    print("<p>Name : <b>$name</b>\n");
    ?>
    </body>
    </html>

    But if I type "Jones" in the name field, it doesn't pass the name
    value on to the form "results" page. It puts it up in the location bar
    as

    /php/results.php?nam e=jones&Submit=

    But it doesn't appear on the Web page.

    What am I doing wrong?

    Thanks for any help.
  • Matthew Crouch

    #2
    Re: i can't seem to pass values with php

    On Sun, 08 Aug 2004 10:38:14 -0700, Matthew Lasar wrote:
    [color=blue]
    > Path:
    > nwrddc01.gnilin k.net!cyclone1. gnilink.net!gni link.net!news.g lorb.com!postne
    > ws2.google.com! not-for-mail
    > From: matthew@lasarle tter.com (Matthew Lasar)
    > Newsgroups: comp.lang.php
    > Subject: i can't seem to pass values with php
    > Date: 8 Aug 2004 10:38:14 -0700
    > Organization: http://groups.google.com
    > Lines: 40
    > Message-ID: <5e4c628e.04080 80938.2e3e0b78@ posting.google. com>
    > NNTP-Posting-Host: 63.203.71.237
    > X-Trace: posting.google. com 1091986695 27940 127.0.0.1 (8 Aug 2004 17:38:15
    > GMT)
    > X-Complaints-To: groups-abuse@google.co m
    > NNTP-Posting-Date: Sun, 8 Aug 2004 17:38:15 +0000 (UTC)
    > Xref: cyclone1.gnilin k.net comp.lang.php:6 4298
    > X-Received-Date: Sun, 08 Aug 2004 13:38:15 EDT (nwrddc01.gnili nk.net)
    > MIME-Version: 1.0
    > Content-Type: text/plain; charset=ISO-8859-1
    > Content-Transfer-Encoding: 8bit
    >
    >
    > I am trying to study php from a book. But the code doesn't seem to
    > work for me. I set up a form, as follows:
    >
    > <html>
    > <head>
    > <title>form</title>
    > </head>
    > <body>
    > <form action="results .php" method="GET">
    > <p>Name: <input type="text" name="name">
    > <P>
    > <input type="submit" name="Submit">
    > <input type="Reset"></form>
    > </body>
    > </html>
    >
    > Then I wrote some code for a processing file titled "results.ph p" as
    > instructed:
    >
    > <head>
    > <title>form results</title>
    > </head>
    > <body>
    > <?php
    > print("<p>Name : <b>$name</b>\n");
    > ?>
    > </body>
    > </html>
    >
    > But if I type "Jones" in the name field, it doesn't pass the name
    > value on to the form "results" page. It puts it up in the location bar
    > as
    >
    > /php/results.php?nam e=jones&Submit=
    >
    > But it doesn't appear on the Web page.
    >
    > What am I doing wrong?
    >
    > Thanks for any help.[/color]


    You just need to grab the value in the (automatically created) variable
    $_GET

    Like so

    $name = $_GET["name"];
    echo $name; // should say "hones"

    Comment

    • Matthew Crouch

      #3
      Re: i can't seem to pass values with php

      [color=blue]
      >
      >
      > You just need to grab the value in the (automatically created) variable
      > $_GET
      >
      > Like so
      >
      > $name = $_GET["name"];
      > echo $name; // should say "hones"[/color]

      Now that I think about it, maybe it should say "jones"

      If it says "hones", please post a follow up. That would be something.

      Comment

      • Geoff Berrow

        #4
        Re: i can't seem to pass values with php

        I noticed that Message-ID:
        <5e4c628e.04080 80938.2e3e0b78@ posting.google. com> from Matthew Lasar
        contained the following:
        [color=blue]
        >I am trying to study php from a book.[/color]

        $_GET a newer book.

        --
        Geoff Berrow (put thecat out to email)
        It's only Usenet, no one dies.
        My opinions, not the committee's, mine.
        Simple RFDs http://www.ckdog.co.uk/rfdmaker/

        Comment

        • Maxim Vexler

          #5
          Re: i can't seem to pass values with php

          Geoff Berrow wrote:[color=blue]
          > I noticed that Message-ID:
          > <5e4c628e.04080 80938.2e3e0b78@ posting.google. com> from Matthew Lasar
          > contained the following:
          >
          >[color=green]
          >>I am trying to study php from a book.[/color]
          >
          >
          > $_GET a newer book.
          >[/color]
          and $_POST the authors of the original book with the words:
          [self, you, shit, little, fu*k, piece, garbage, go] for writing this book.

          Comment

          • Tim Tyler

            #6
            Re: i can't seem to pass values with php

            "Maxim Vexler <hq4ever (at) 012 (dot) net (dot) il>" <"Maxim Vexler <hq4ever (at) 012 (dot) net (dot) il>"> wrote or quoted:[color=blue]
            > Geoff Berrow wrote:[color=green]
            > > <5e4c628e.04080 80938.2e3e0b78@ posting.google. com> from Matthew Lasar[/color][/color]
            [color=blue][color=green][color=darkred]
            > >>I am trying to study php from a book.[/color]
            > >
            > > $_GET a newer book.[/color]
            >
            > and $_POST the authors of the original book with the words:
            > [self, you, shit, little, fu*k, piece, garbage, go] for writing this book.[/color]

            PHP *used* to work that way.

            The book's code probably worked correctly when it was written.
            --
            __________
            |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.

            Comment

            • Maxim Vexler

              #7
              Re: i can't seem to pass values with php

              Tim Tyler wrote:[color=blue]
              > "Maxim Vexler <hq4ever (at) 012 (dot) net (dot) il>" <"Maxim Vexler <hq4ever (at) 012 (dot) net (dot) il>"> wrote or quoted:
              >[color=green]
              >>Geoff Berrow wrote:
              >>[color=darkred]
              >>><5e4c628e.04 08080938.2e3e0b 78@posting.goog le.com> from Matthew Lasar[/color][/color]
              >
              >[color=green][color=darkred]
              >>>>I am trying to study php from a book.
              >>>
              >>>$_GET a newer book.[/color]
              >>
              >>and $_POST the authors of the original book with the words:
              >>[self, you, shit, little, fu*k, piece, garbage, go] for writing this book.[/color]
              >
              >
              > PHP *used* to work that way.
              >
              > The book's code probably worked correctly when it was written.[/color]
              really? didn't know that.
              i dive php since version 4

              ok then, cancel the $_POST :)

              Note to self: next time SHUT-UP !

              Comment

              • Michael Fesser

                #8
                Re: i can't seem to pass values with php

                .oO(Maxim Vexler <hq4ever (at) 012 (dot) net (dot) il>)
                [color=blue]
                >Geoff Berrow wrote:
                >[color=green][color=darkred]
                >>>I am trying to study php from a book.[/color]
                >>
                >> $_GET a newer book.
                >>[/color]
                >and $_POST the authors of the original book with the words:
                >[self, you, shit, little, fu*k, piece, garbage, go] for writing this book.[/color]

                Calm down and take a $_COOKIE. Prior to 4.2.0 PHP worked as described in
                the book. In 4.2.0 the default value for register_global s went to OFF.

                Using Register Globals


                Micha

                Comment

                Working...