# My first php program ... not working

**URL:** <https://www.phphelp.com/t/my-first-php-program-not-working/11010>\
**Category:** Beginners - Learning PHP\
**Created:** [March 10, 2008, 12:31pm UTC](https://www.phphelp.com/t/my-first-php-program-not-working/11010 "2008-03-10T12:31:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dgreen](https://www.phphelp.com/letter_avatar_proxy/v4/letter/d/9e8a1a/32.png) [@dgreen](https://www.phphelp.com/u/dgreen)\
**Post date:** [March 10, 2008, 12:31pm UTC](https://www.phphelp.com/t/my-first-php-program-not-working/11010/1 "2008-03-10T12:31:54Z")

</div>

I am teaching myself PHP with “Beginning PHP4, (WROX)” and for the life of me I can’t get this to work and I don’t see anything wrong. This example is from the book.

Who is your favorite author?  
  
------------------------------------------------- Your favorite author is: \<?php echo $author; ?\> ------------------------------------------------ If I type g-r-e-e-n and press submit ..... I get Your favorite author is: b-l-a-n-k The value of the variable is never printed. My browser is Firefox. I've double and triple checked the spelling.

Thanks for your help … Don

---

<div class="post-metadata">

**Author:** ![Zyppora](https://www.phphelp.com/letter_avatar_proxy/v4/letter/z/76d3ee/32.png) [@Zyppora](https://www.phphelp.com/u/Zyppora)\
**Post date:** [March 10, 2008, 12:35pm UTC](https://www.phphelp.com/t/my-first-php-program-not-working/11010/2 "2008-03-10T12:35:04Z")

</div>

Your book expects register\_globals to be enabled. This poses a security hole however, and has been disabled by default since PHP4.? somewhere halfway PHP4. You’ll want to catch your external values using the $\_GET superglobal:

```auto
echo $_GET['author'];
```

Most forms use ‘method=“POST”’ though, in which case $\_POST should be used.

---

<div class="post-metadata">

**Author:** ![samtvmus](https://www.phphelp.com/letter_avatar_proxy/v4/letter/s/85f322/32.png) [@samtvmus](https://www.phphelp.com/u/samtvmus)\
**Post date:** [March 17, 2008, 4:39pm UTC](https://www.phphelp.com/t/my-first-php-program-not-working/11010/3 "2008-03-17T16:39:45Z")

</div>

Friend,

Have you obtained correct output?

I have a similar problem while i accept a name in HTML and print in PHP code. I tried the echo $\_GET[‘DATA’]; and also echo $\_POST[‘DATA’]; options. No output for me. ![:roll:]()

---

<div class="post-metadata">

**Author:** ![dgreen](https://www.phphelp.com/letter_avatar_proxy/v4/letter/d/9e8a1a/32.png) [@dgreen](https://www.phphelp.com/u/dgreen)\
**Post date:** [March 17, 2008, 5:05pm UTC](https://www.phphelp.com/t/my-first-php-program-not-working/11010/4 "2008-03-17T17:05:53Z")

</div>

\<?php echo $\_GET['data']; ?\>

This works for me.

DG
