Passing POST data from one web page to another with PHP

前端 未结 5 730
天命终不由人
天命终不由人 2020-12-19 05:44

Searching did not find a similar question, so: How can POST data used by PHP to generate one page be passed from that page to another PHP generated page? I have:

5条回答
  •  半阙折子戏
    2020-12-19 06:25

    I recall struggling with this issue long ago, wondering why I simply couldn't redirect with a modified POST header. The reason is a redirect is actually considered a GET.

    Regardless, you need to store the post variables in hidden fields.

    
    

    I would recommend prefixing all your field names from each form so that its easy to tell them apart during your consolidation phase at the end.

    
    
    

    Edit: As others have mentioned, persisting data using sessions is one possibility, but this becomes a very complex matter of maintaining temporary state which things like page refreshes or using the back button can make difficult to maintain. Unless you're facing an extreme case, it's much easier to persist data using fields since they survive refreshes and other browser behaviour much more easily.

提交回复
热议问题