Post/Get Method Seems Not Working

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Post/Get Method Seems Not Working

Postby s_g » 04. October 2006 03:36

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.
s_g
 
Posts: 2
Joined: 04. October 2006 02:52

Postby Wiedmann » 04. October 2006 04:22

Read the PHP manual about how to use "Variables from outside PHP".

(And throw the book into the waste-paper basket :wink:)
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby s_g » 04. October 2006 05:10

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.
s_g
 
Posts: 2
Joined: 04. October 2006 02:52

Postby Wiedmann » 04. October 2006 05:36

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']).
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 62 guests