Injecting Value into POST w/o an actual value

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
McManCSU
Forum Newbie
Posts: 22
Joined: Mon Apr 23, 2007 6:30 pm

Injecting Value into POST w/o an actual value

Post by McManCSU »

I am trying to insert a value the POST array of some value that is not used anywhere (not a hidden value, button, etc.) The use is for sequential page step process. I use a hidden field for the current page, which is then incremented. I need to keep track of the previous page using POST. I do something like:

$_POST[prev] = $_POST[current];

The previous is fine until I switch to the next page, and is then removed from POST.

I tried having two hidden variables, but the next page would never be displayed...

Ideas?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

The $_POST array only contains data from the page that posted to it. You can't post from within PHP.

Try looking into $_SESSION.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

Normally you pass this sort of information from the form as a hidden form field if you are using a form and submit buttons rather than links for Next and Previous.

In general though I tend to have any "buttons" for Next/Previous as links with a $_GET variable passed

Code: Select all

<a href="http://your_url.html?page=1">&lArr;Previous</a>
&nbsp;Currently on Page 2 of 10&nbsp;
<a href="http://your_url.html?page=3">Next&rArr;</a>
OK the &nbsp; would probably be dependant on design maybr CSS left and right but you get the picture I hope. I find this method to be a lot cleaner than using forms. Also you do not not into problems with multiple forms when designing a "wizard". It's also cleaner for users who use some browsers which ask about $_POST values etc when using the browser back button rather than your links.

If you want to solve the problem you actually have using $_POST values can you post some code?
Post Reply