douxian3170 2010-02-28 10:37
浏览 21

发送后形成问题(cookie问题)

I get a strange error after submitting a form the error is this one:

        Warning: Cannot modify header information - headers already sent by 
        (output started at
        /var/www/g35003/coldcharlie.nl/subdomains/test/mailer.php:6) in 
        /var/www/g35003
        /coldcharlie.nl/subdomains/test/mailer.php on line 96

Line 96 contains this

// delete the cookie so it cannot sent again by refreshing this page
    setcookie('tntcon','');

This is the complete mailer.php

// ----------------------------------------- 
//  The Web Help .com
// ----------------------------------------- 
// remember to replace you@email.com with your own email address lower in this code.

// load the variables form address bar
$subject = $_POST["subject"];
$message = $_POST["message"];
$from = $_POST["from"];
$verif_box = $_POST["verif_box"];

// remove the backslashes that normally appears when entering " or '
$message = stripslashes($message); 
$subject = stripslashes($subject); 
$from = stripslashes($from); 

// check to see if verificaton code was correct
if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){
    // if verification code was correct send the message and show this page
    mail("info@friesecomputerservice.nl", 'Online Formulier: '.$subject, $_SERVER['REMOTE_ADDR']."

".$message, "From: $from");
    // delete the cookie so it cannot sent again by refreshing this page
    setcookie('tntcon','');
} else if(isset($message) and $message!=""){
    // if verification code was incorrect then return to contact page and show error
    header("Location:".$_SERVER['HTTP_REFERER']."?subject=$subject&from=$from&message=$message&wrong_code=true");
    exit;
} else {
    echo "no variables received, this page cannot be accessed directly";
    exit;
    }
?>

This is the head section of my mailer.php

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="description" content="Computerhulp voor Particulieren en MKB in Leeuwarden en de rest van Friesland" />
    <meta name="keywords" content="computerhulp in friesland, pc service, Leeuwarden, Sneek, Drachten, Heerenveen, Bolsward, Buitenpost, Franeker, Gorredijk, Dokkum, Joure, Oosterwolde, Koudum, Harlingen " />
    <title>Computer stuk? Computerhulp nodig? Friese Computer Service - Leeuwarden, Sneek, Drachten, Heerenveen, Bolsward, Buitenpost, Franeker, Gorredijk, Dokkum, Joure, Oosterwolde, Koudum, Harlingen, Computerhulp Friesland</title>
    <link rel="bookmark" href="/favicon.ico" />
    <link rel="shortcut icon" href="/favicon.ico" />

    <link href="http://www.coldcharlie.nl/test/css/style.css" rel="stylesheet" type="text/css" />
  </head>
  • 写回答

1条回答 默认 最新

  • dongluan5740 2010-02-28 10:42
    关注

    Modifying the HTTP header is only possible if it was not sent to the client yet. And that takes place when you print something out.

    And in your case the output starts at the line 6 in your mailer.php file. You can use the output buffer functions and buffer the output to avoid that.

    评论

报告相同问题?

悬赏问题

  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题