Page 1 of 1

Post/Get Method Seems Not Working

PostPosted: 04. October 2006 03:36
by s_g
Hi all,

I recently installed the XAMPP 1.5.4 on my laptop to learn PHP and MySQL programming.

What I have been following is this book, and in the second chapter, a use of Post/Get method with php is introduced.

The codes are very simple. In the first page called whatsName.html, users can type a name and press the submit. And the name is desplayed in the next page, hiUser.php.

But this does not work on my computer. In the url, the submitted value is certainly desplayed such as hiUser.php?userName=test. However, the name does not get displayed in that page. Other elements are properly displayed but it's just missing the value sent from the previous page.

The book has a CD and I tried the files in the CD for that instrution. With no luck, I got the exactly the same result as I had tried by myself. So I have the correct codes but does not work.

I guess there must be something wrong with the server, maybe the php? I don't know. The PHP Version is 5.1.6. Did I have to turn on some extensions in order to accept the Post/Get method?

Any informaion would be greatly appreciated.

PostPosted: 04. October 2006 04:22
by Wiedmann
Read the PHP manual about how to use "Variables from outside PHP".

(And throw the book into the waste-paper basket :wink:)

PostPosted: 04. October 2006 05:10
by s_g
It was all about the "register_globals = On"

Thank you for the information. I really apprecate it. My 3 nights trouble's gone by just 3 minutes reading.

By the way, the book is not so bad though. Just I was so stupid that I skipped the first chapter that says to turn it on.

PostPosted: 04. October 2006 05:36
by Wiedmann
It was all about the "register_globals = On"

No. Setting this to "On" is wrong (and of course bad). And no more availible with the next PHP mayor release.

This setting is "off" since 6 years and this switch is/was only in the php.ini, to let PHP3 scripts work with PHP4. (bad they have forgotten to remove them in PHP5).

As you can read in the PHP manual:
With this link "hiUser.php?userName=test". You must use the variable $_GET['test'] to get the value (and not $test like your book told you).

BTW:
I can really not understand, why people can read in some books, they should change the register_globals to on. In fact, this people will lern wrong programing techniques (and it's not easier to use $test instead of the correct $_GET['test']).