fcleffer Posted December 24, 2007 Share Posted December 24, 2007 ??? 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 https://forums.phpfreaks.com/topic/83077-newbie-question-chapter-three-is-killing-me/ Share on other sites More sharing options...
raku Posted December 24, 2007 Share Posted December 24, 2007 Hi, If the form action is sent to get as I think it is since you said the variable is in the URL, you can access the variable like this: $username = $_GET['username']; Hope this helps. Link to comment https://forums.phpfreaks.com/topic/83077-newbie-question-chapter-three-is-killing-me/#findComment-422628 Share on other sites More sharing options...
raku Posted December 24, 2007 Share Posted December 24, 2007 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 https://forums.phpfreaks.com/topic/83077-newbie-question-chapter-three-is-killing-me/#findComment-422629 Share on other sites More sharing options...
corbin Posted December 24, 2007 Share Posted December 24, 2007 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 https://forums.phpfreaks.com/topic/83077-newbie-question-chapter-three-is-killing-me/#findComment-422636 Share on other sites More sharing options...
fcleffer Posted December 25, 2007 Author Share Posted December 25, 2007 The Get helps ... Learning from a very OLD BOOK doesn't work!! Thanks Link to comment https://forums.phpfreaks.com/topic/83077-newbie-question-chapter-three-is-killing-me/#findComment-422695 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.