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?

Link to comment
Share on other sites

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";

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.