The moose likes PHP and the fly likes Simple PHP problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » PHP
Bookmark "Simple PHP problem" Watch "Simple PHP problem" New topic

Simple PHP problem

colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 750
Hi, I'm using the book...PHP for the world wide web

In chapter 3 there are two scripts, form.html and HandleForm.php shown below:

But when I run it and enter data, I get this..

Your first name is .
Your last name is .
Your E-mail address is .
This is what you had to say:

For some reason the $name is just blank.
My web hosting uses PHP5, and the book is for PHP 3 and 4, but I doubt thats why.

Can anyone help??
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

Either the book is wrong or you're missing a step. If you post a form in PHP, you have to get the values from the $_POST variable like so...

Not sure what they are doing in the code you've posted.

GenRocket - Experts at Building Test Data
colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 750
Thanks, yes thats right, apparently its a security thing new to PHP5.

So you use GET for get requests, and POST for post requests.
I hope my 2 php books aren't too outdated with regards to other bits of code.
Rafael Monteiro Dourado

Joined: Jul 29, 2010
Posts: 9
guy this book is old, try another one like the "PHP 5 Power Programming" .

Web Programmer
Matthew Brown

Joined: Apr 06, 2010
Posts: 4541

The feature is called "Register Globals". In old versions of PHP what you're doing was allowed by default, but in PHP 4.2 it was disabled by default for security reasons. And in PHP5 it's officially deprecated. Don't use it .
I agree. Here's the link:
subject: Simple PHP problem
jQuery in Action, 3rd edition