How do I pass data between pages in PHP?

后端 未结 5 1467
遇见更好的自我
遇见更好的自我 2020-12-01 20:01

In a nutshell on \"page1.php\" I have a calculator that consists of an HTML form, and then the PHP code totals the input and displays the total price. Below the price, it al

5条回答
  •  隐瞒了意图╮
    2020-12-01 20:35

    little late on the answer, yes, best way is using type=hidden as others have mentioned already.

    page1 sends _POST to page2, which "saves" all of it in hidden fields, so it can send everything together to the final (or another) page.

    but more importantly, and going to a broader-topic, is considering why using pages at all to divide a form!

    sorry for touching this subject here, I just felt like giving my 2 cents.

    don't page forms

    I'd say best thing is avoid paging as much as possible and only good reasons to do it so would be if you need server validation and backwards compatibility with browsers that won't accept javascript.

    use newer resources instead

    layout and design can both be achieved using javascript and CSS, which are both meant for that. even if you do the user to "press next", use dhtml and all in 1 file. need server validation? ajax.

    unless you're using HTML frames (which you probably shouldn't), loading a whole page is a redundant and unnecessary server and client load that takes more time in both using and programming (to take care of passing form info from one place to another).

    and it's far from being the best way to save the state of what's being done. granted, this is a whole complicated subject on its own, but again, ajax would be best here.

提交回复
热议问题