PHP表单重定向到网页
我有一个条目表单需要重定向到付款页面,我正在努力排序,下面是我的代码:PHP表单重定向到网页,php,forms,redirect,Php,Forms,Redirect,我有一个条目表单需要重定向到付款页面,我正在努力排序,下面是我的代码: if(mail($recipient, $subject, $email_content, $email_headers)) { // Set a 200 (okay) response code. http_response_code(200); echo "Thank You For Entering. You need to make a payment now";
if(mail($recipient, $subject, $email_content, $email_headers)) {
// Set a 200 (okay) response code.
http_response_code(200);
echo "Thank You For Entering. You need to make a payment now";
这就是我想要它做的:
if(mail($recipient, $subject, $email_content, $email_headers)) {
// Set a 200 (okay) response code.
http_response_code(301); window.location='payment.html');
我知道下面的代码不起作用,我就是看不出代码是否正确
可能吗?使用标题功能
if(@mail($recipient, $subject, $email_content, $email_headers)) {
// Set a 200 (okay) response code.
http_response_code(301);
header('location: http://yourdomain.com/payment.html');
使用PHP函数头()-window.location是javascript函数。您需要使用PHP函数头('location:);有人建议在这些评论和答案中使用
header()
,这是正确的,这就是您在PHP中重定向的方式-但是没有提到,如果您已经有任何输出,它将无法工作!任何HTML、空格、echo
或print
都将被输出,并且头()的使用将失败。
!非常感谢,虽然这正是我想做的,但也没有用,令人沮丧。仍然没有,我想我必须继续尝试,谢谢你的帮助。@mail()会告诉你是真是假;我通过使所有参数都相同的http_响应_代码(302),成功地将其转发到html页面;标题('位置:);}