Jump to content

Newbie - Question - Chapter Three is Killing Me!


fcleffer

Recommended Posts

???

 

I am working through a book Professional PHP Programming - 1999 Wrox Press. I know it's OLD! On pg 68 I created a Variable - easy - Hard coded $username="Eric"; <? ECHO ($username); ?> Works .. Cool!

 

next it says you can create same variable by inputing HTML FORM  <HTML><FORM> Type Your Name<BR><INPUT TYPE=TEXT NAME=username>  ... blah blah submit.  Then!

 

<? echo ($username); ?>  -- TEXT shows in URL but doesn't echo anything.

 

(HTML) NAME=username  creates (PHP) variable $username

 

I have tried Firefox and IE because I thought my browser might be blocking the variable.  ??Has the syntax changed from the php v.3 to the v.5??  Do I need to reconfigure Apache?  Am I a bonehead?

Sorry, I meant to say:

 

If the form action is set to "get", not sent.

 

To elaborate a little.. get means that the variable is in the URL like:

 

www.example.com/example.php?username=hi

 

$username = $_GET['username'];

echo $username;

 

Should output "hi";

That book assumes super globals is on....

 

No offense, but a 1999 book might be a little.... Too old.

 

PHP has changed A LOT in 8 years....

 

Also, there's a lot of online tutorials now.

 

For this problem, I suggest reading about $_GET and $_POST.

 

http://www.w3schools.com/php/php_get.asp

http://www.w3schools.com/php/php_post.asp

http://www.tizag.com/phpT/postget.php

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.