不能用mail()和header()php修改头信息与ob_start() [英] Cannot modify header information with mail() and header() php with ob_start()

查看:402
本文介绍了不能用mail()和header()php修改头信息与ob_start()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确信你们都知道这个错误:

I am sure you all know this error:

警告:不能修改标题信息 - 已经发送的标题/4/d374499247/htdocs/wp-content/themes/tyler/mail.php:1)在/homepages/4/d374499247/htdocs/wp-content/themes/tyler/mail.php第34行

这是代码:

if (strpos($email,'@') !== false)  {
    ob_start();
    mail($to,$subject,$message,$headers);
    header("Location: thankyou.html");
    ob_end_flush(); }

任何人都可以提供任何帮助?我只是想要邮件()的信息,然后去位置页面

Could anyone offer any help here? I just want it to mail() the information and then go to the Location page

编辑:这是整个代码..

Here is the entire code..

<?php
$to = 'myemail@gmail.com';
$subject = 'בקשת הצטרפות לרשימת תפוצה';
$message =
'בקשת הצטרפות לרשימת תפוצה' . "\n\n" .
'שם: ' . $_REQUEST['name'] . "\n\n" .
'דואר אלקטרוני: ' . $_REQUEST['email'];
$email = $_REQUEST['email'];
$headers = 'From: ' . $email . "\r\n" .
            'Reply-To: ' . $email . "\r\n" .
          'X-Mailer: PHP/' . phpversion();
$headers .= "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type: text/plain; charset=ISO-8859-1";
// server-validation
if (strpos($email,'@') !== false){
    mail($to,$subject,$message,$headers);
    header("Location: thankyou.html");
} else {
    echo "<p class='error'>כתובת הדוא'ל שגויה.</p>";
}
?>


推荐答案

检查您的页面编码。可能是UTF-8 +(使用 UTF-8签名

Check your page encoding. Probably it UTF-8+ (with UTF-8 signature)

如果没有,那么你需要检查空格。

If not then you need to check white spaces.

这篇关于不能用mail()和header()php修改头信息与ob_start()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆