$_POST not working in next 2 pages ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ashebrian
Forum Contributor
Posts: 103
Joined: Sat Feb 02, 2008 8:01 pm

$_POST not working in next 2 pages ?

Post by ashebrian »

I'm still learning php. I've got a page where i post info taken from the first page to the next .... like:

Code: Select all

<?php echo $_POST["price"]; ?>
. That works fine....BUt when i use the same code again for the page after that it doesn't seem to come up at all.....just blank. I persume that the variable

Code: Select all

$_POST
only works once, but u can't post it again using the same code.

Does anybody know a solution to this? Or will i have to setup a table in the db to call the info to the next page?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: $_POST not working in next 2 pages ?

Post by Christopher »

You need to put the price into a hidden field on each page like:

Code: Select all

<input type="hidden" name="price" value="<?php echo intval($_POST['price']); ?>"/>
(#10850)
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: $_POST not working in next 2 pages ?

Post by Zoxive »

Post only works on the file/page you submit the form to.

A solution would be using $_GET, or $_SESSION.
Post Reply