PHP - Pass POST variables with header()?

前端 未结 4 1931
伪装坚强ぢ
伪装坚强ぢ 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条回答
  •  轮回少年
    2020-12-14 11:09

    Provided that you have local access to the page displaying the error, instead of redirecting you could include it in the page which caused the error and then programmatically display the error message.

    if(something_went_wrong()) {
      require_once('errors.php');
      display_error('something really went wrong.');
      }
    

    The errors.php file would then contain a definition for display_error($message), which displays the formatted message.

提交回复
热议问题