php does not display variables

$_POST variables not displaying in PHP

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 2479 Views - Last Post: 01 May 2010 - 12:54 PM Rate Topic: -----

#16 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5678
  • View blog
  • Posts: 22,540
  • Joined: 23-August 08

Re: php does not display variables

Posted 30 April 2010 - 10:33 PM

I suspect your book is old and relies on the register_globals setting to be on, which it should not be (and won't be in newer versions of PHP).

Is this all in a single file called calculation.php?

If not, it should be, and the PHP must precede the HTML, as ahmad_511 said a few replies back. I did this on my local system and it works just fine.

This post has been edited by JackOfAllTrades: 30 April 2010 - 10:51 PM
Reason for edit:: More info

Was This Post Helpful? 0
  • +
  • -

#17 ahmad_511  Icon User is offline

  • MSX
  • member icon

Reputation: 125
  • View blog
  • Posts: 704
  • Joined: 28-April 07

Re: php does not display variables

Posted 30 April 2010 - 10:50 PM

also, when you have a mix of php / html, make sure that you save the file as .php so it can be interpreted by PHP
Was This Post Helpful? 1
  • +
  • -

#18 jptenney  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 28-April 10

Re: php does not display variables

Posted 01 May 2010 - 11:48 AM

Does it have to be in the same file. I've done it that way but have yet to test it.

works fine in my single file format, but can it be done by calling the php file. Is it that the page is being reset each time?
Was This Post Helpful? 0
  • +
  • -

#19 Stephen Isienyi  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 16
  • Joined: 11-November 08

Re: php does not display variables

Posted 01 May 2010 - 12:54 PM

You need two pages. And also change the input type for the count field to text. You may also make readonly by adding ReadOnly="ReadOnly".

The first page is an html page containing simply the form without the php script. The form's action would point to the address of the second page. You may set the value of the count field to 0: value="0"

The second page is a php file. You would place the php script on top so that it processes the $_POST array from the html page, and increment the value of count accordingly. Then you may echo out the .html form underneath the script. Set count field: e.g. value = "<?php echo $countVarable ?>."

You may also create another php page similar to the second page. The form action from the second page would point at this page's address, and the form action from this third page would point second page's address.

Goodluck with your project.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2