开发者

Is it possible to send an email and auto redirect in single php file?

开发者 https://www.devze.com 2022-12-24 11:17 出处:网络
As the title said: Is it possible to send an email (using php mail()) and after sending the email, auto redirect to another page. All开发者_如何学Go the codes will be in single php file?

As the title said:

Is it possible to send an email (using php mail()) and after sending the email, auto redirect to another page. All开发者_如何学Go the codes will be in single php file?

Code-wise, should be something like this:

if(mail(argument...)){
    header("Location: www.google.com");
}

I think I would get a: "Error: header information already sent" or something like. But what if I want to send email and then auto-redirect on that page?? Possible?


This error:

Error: header information already sent 

usually caused by having white space before the opening and closing PHP tags or something was printed to the browser before preparing the page.

If this is the only code you have

if(mail(argument...)){
    header("Location: www.google.com");
}

it will work because you are not printing anything to the browser but be sure to avoid including white spaces.

0

精彩评论

暂无评论...
验证码 换一张
取 消