For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > June 2006 > The GET-arguments (?)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author The GET-arguments (?)
Henk Oegema

2006-06-19, 7:02 pm

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/basebal...&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
Bert Melis

2006-06-19, 7:02 pm

Using PHP with it's current version, register globals is disabled by
default.

Therefore, any variable passed by the user (POST, GET,...) is only
accessible by using the global arrays $_GET or $_POST.

try this

echo $_GET['Team'];


PS you should also review your html...

Regards,
Bert (Belgium)


"Henk Oegema" <henk@oegema.com> wrote in message
news:Y0Dlg.491701$7F7.12585033@phobos.telenet-ops.be...
>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/basebal...&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



ED

2006-06-19, 7:02 pm


"Henk Oegema" <henk@oegema.com> wrote in message
news:Y0Dlg.491701$7F7.12585033@phobos.telenet-ops.be...
>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/basebal...&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



Hi Henk, couple of issues here:

1) to pass the Submit variable you need to name the Submit element:
<input type="submit" name="Submit" value="Submit">

2) instead of printing $Team try printing $_GET['Team'].
It sounds like register globals are turned off (as they should be) and you
need to access request variables through the appropriate superglobal array
(in this case $_GET - if the form used the POST method you would use the
$_POST array). Please see: http://uk2.php.net/register_globals

cheers
ED



Henk Oegema

2006-06-19, 7:02 pm

ED wrote:

>
> "Henk Oegema" <henk@oegema.com> wrote in message
> news:Y0Dlg.491701$7F7.12585033@phobos.telenet-ops.be...

The mistake was from the book(PHP4 Bible, Tim Converse and Joyce Park (Dutch
translation))
The line input="submit".......was incomplete !!
[color=darkred]
========================================
==================================[color
=darkred]
>
>
> Hi Henk, couple of issues here:
>
> 1) to pass the Submit variable you need to name the Submit element:
> <input type="submit" name="Submit" value="Submit">
>
> 2) instead of printing $Team try printing $_GET['Team'].
> It sounds like register globals are turned off (as they should be) and you
> need to access request variables through the appropriate superglobal array
> (in this case $_GET - if the form used the POST method you would use the
> $_POST array). Please see: http://uk2.php.net/register_globals
>
> cheers
> ED


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com