dongwei9771 2016-01-03 07:00
浏览 10

PHP标题功能行在我想要的文件中不起作用,它适用于所有其他文件

I am working with a mail. What I exactly want is the page should be redirected to the universal resource locator after 5 seconds. The header line is working fine in all other files but not in this file. I tried my best to find what is wrong. The before and after line is also working fine but the page is not redirecting. And even I have checked the code many time and there is no error.

Can you please tell me the reason why is it happening?

Code

<?php
   if (isset($_POST['fullname']) && isset($_POST['email']) && isset($_POST['message']) && isset($_POST['submit'])) {
      $fullname = $_POST['fullname'];
      $email = $_POST['email'];
      $message = $_POST['message'];
      $to = "ziajappa1@gmail.com";
      $subject = "Customer";
      $txt = "Hi, Grand4Love  ".$fullname." have contacted you. Do hurry to contact him back! The user's email address is: ".$email."";
      $headers = "From: client@perfecttips.com
";
      //."CC: somebodyelse@example.com";

      if(mail($to,$subject,$txt,$headers)){
         echo "<h2>Thank you for contacting us, we will respond to your message withing 24 hrs<h2>";
      }

      header('refresh:5; url=http://perfecttips.co/'); 
      // The above line is working in the other files but not here. 
      // Please suggest me why the above line is not working?
      echo "hi";
   }
?>
  • 写回答

1条回答 默认 最新

  • duanche5149 2016-01-03 07:21
    关注

    Is there anything that is included in this file that is written to the response before the header is parsed?

    Headers need to be the first thing that page parses, or else it will be ignored.

    Look for echoes or something in previously imported files.

    Edit:Yup. You are echoing. Comment out all echoes and you'll see it should work.

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集