|
Posted by Kim Andrι Akerψ on 06/19/06 20:35
Henk Oegema wrote:
> I have just started teaching myself PHP language.
> I'm studying an article about "GET", to pass arguments from one page
> to another.
>
> It is not working the way it is suppose to.
> And I can't figure out what the problem (mistake) is.
>
>
> This file should pass a argument to the file baseball.php
> ======================================================================
> <html>
> <head>
> <title>A GET example, part 1</title>
> </head>
>
> <body>
> <form action="http://192.168.123.100/PHP4/baseball.php" method="GET">
> <p>Root, root, root, for the:<br>
> <select name="Team" size=2>
> <!-- It's a good idea to use the VALUE attribute even though it is
> not mandatory with the SELECT element. In this example, it's
> extremely necessary. -->
> <option value="Cubbies">Chicago Cubs (National League)
> <option value="Pale Hose">Chicago White Sox (American League)
> </select>
> <p><input type="submit">
> </form>
> </body>
> </html>
> ======================================================================
> =
>
> File baseball.php:
> ======================================================================
> = <html>
> <head>
> <title>A GET example, part2</title>
> <style type="text/css">
> <!--
> body {font-size:24pt;}
> -->
> </style>
> </head>
>
> <body>
> <p>Go,
> <?php print("$Team"); ?>
> !
> </body>
> </html>
> ======================================================================
> ====
>
> If the user makes a selection and presses SUBMIT in the first file,
> than the browser put those elements together, without spaces.
> The following URL string should be made:
> http://192.168.123.100/PHP4/baseball.php?Team=Cubbies&Submit=Submit.
> So the output should be: Go, Cubbies!
>
> However, what I get is:
> http://192.168.123.100/PHP4/baseball.php?Team=Cubbies (&Submit=Submit
> is missing !
> My output is: Go, !
>
> The variable output is missing.
> After many hours of searching I still haven't found the problem.
>
> Thanks for any help.
> Henk Oegema
Input fields without a name arent't included in the submitted data.
So, change this:
<p><input type="submit">
To this:
<p><input type="submit" name="Submit" value="Submit">
Also, $Team will only work if register_globals is set to "on" in the
PHP configuration file (php.ini).
A more reliable way is to use this format:
print($_GET["Team"]);
--
Kim AndrΓ© AkerΓΈ
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
[Back to original message]
|