PHP - Pass POST variables with header()?

前端 未结 4 1937
伪装坚强ぢ
伪装坚强ぢ 2020-12-14 10:14

I\'m trying to use the header() function to create a redirect. I would like to display an error message. Currently I\'m sending the message as a parameter through the URL,

4条回答
  •  猫巷女王i
    2020-12-14 11:09

    When passing variables between modules I have found it easier to construct an array from the variables, convert the array to json and store it in a db table with two columns, a varchar key and a text data. The json would go in data and the key could be anything you want. Then in the target module you just read that back, convert the json back to an array and voila, you have your variables. No $_POST, no $_SESSION, no fuss, no muss, quick and easy. Of course that assumes you have access to a database, although you could use a file on the server. $_POST is useless since it needs a and $_SESSION can be cranky and can lead to unexpected results. Otherwise you'd almost have to use ajax.

提交回复
热议问题