PHP header() will not redirect issue

后端 未结 1 989
自闭症患者
自闭症患者 2021-01-17 03:04

I\'m having an issue with the header(\"Location: index.php?action=messagesent\") it will not redirect after The user presses submit and the php is ran. Normally it will redi

相关标签:
1条回答
  • 2021-01-17 03:37

    A header(Location: ...) will only work if you have not already sent output to the browser.

    Earlier in your script you output the form, hence header() fails with an error message.

    If you look in your error log, you will see the error message.

    Add error reporting to the top of your file(s) while testing right after your opening PHP tag for example

    <?php 
    error_reporting(E_ALL); 
    ini_set('display_errors', 1);
    

    Now you will see the errors on the browser page.

    0 讨论(0)
提交回复
热议问题