contact form PHP redirect is not working

前端 未结 7 410
迷失自我
迷失自我 2021-01-20 01:42

I im trying to redirect to my homepage after submitting a message on my contact form, the form sends the email but I get this message:

Array
(
    [name] =&g         


        
7条回答
  •  情话喂你
    2021-01-20 01:52

    You can't output anything to the screen before redirecting.

    Remove all your echo'es and print_r's and you should be fine.

    EDIT:

    Also as @jhonraymos mentioned, be sure to use header() properly. Maybe you changed this to hide your actual page you're redirecting to. Either add a local file with correct path definitions or if redirecting to an other domain, you need to define the full url. See Uniform resource locator if in doubt.

    Another EDIT:

    I see you updated your question. Stop trying indian magic, such as

    if ($success){
        print "";
    

    Just accept the fact not to output ANYTHING to the screen before headers() and your soul is safe forever. This is not the place to mix http-meta in. PHP can do this just fine.

    This might sound as a limitation first, but believe me, it isn't. It's a blessing.

提交回复
热议问题