2013-01-13 27 views
0

我正在创建一个通讯系统,用于跟踪打开电子邮件时所有类型的信息。使用php图像跟踪技巧在电子邮件中显示图像

我已经开始用它看起来像

<p><img src="http://xxx.com/newsletterInfo.php?newsletter=12&userid=234" width="314" height="20" alt="Cancel Newsletter Subscription"></p> 

然后在newsletterInfo.php文件我正在echo'ing的URL图像的图像。

我认为这不是这样做的方式吗?

有人可以请指出我的问题在哪里。

感谢

更新

电子邮件的发送:

  $name = stripslashes($fetchquery["name"]); 
      $email = stripslashes($fetchquery["email"]); 

      $content = $_POST["maincontent"]; 
      $subject = $_POST["subject"]; 
      $message = "<html><head><title>".$subject."</title></head><body>"; 
      $message .= str_replace('{name}', $name, $content); 
      $message .= '<p><img src="http://xxx.com/newsletterInfo.php?newsletter='.$id.'" width="314" height="20" alt="Cancel Newsletter Subscription"></p>'; 
      $message .= "</body></html>"; 

      $headers = 'MIME-Version: 1.0' . "\r\n"; 
      $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; 
      $headers .= 'From: Username <[email protected]>' . "\r\n"; 

      // Mail it 
      mail($email, $subject, $message, $headers); 

在信息页面上,我已经做到了这一点:

if(isset($_GET["newsletter"])) { 

    $query = $pdo->prepare("UPDATE newsletter SET opened=`opened` +1 WHERE id=:id"); 
    $query->execute(array(':id' => $_GET["newsletter"])); 
    $query_num = $query->rowCount(); 

    if($query_num > 0){ 
     echo 'http://xxx.com/cancel.png'; 
    } 

正如你所看到的电子邮件使用ma发送电子报il()函数,然后在那里图像是我把PHP文件的URL,在这个文件要求的变量,如果它设置它然后回声图像URL,然后输入数据到数据库中,所有这些工程100%因为数据库正在更新。

问题是图像坏了。

如果你点击右键,进入newsletterInfo.php网址显示。

我认为这根本不是这样做的方式。

+0

为什么这不是这样做的?有什么问题 ? – vodich

+0

@vodich对不起,我忘了实际上说图像没有显示。我不明白你的意思是“为什么这不是这样做?”谢谢 – Robert

+0

粘贴一些代码,以便我们可以看到代码中的错误 – vodich

回答

1

src属性应指向图像。您的src指向包含URL的(动态)文本文件,而不是实际图像。 newsletterInfo.php应该输出一个图像,而不是它的URL。

可能的解决方案:

  1. 简单的办法:做一个重定向内newsletterInfo.php,就像这样:

    header('Location: url_to_the_image.jpg'); 
    

    (与您目前正在重复着替换的文件名并删除回声)

  2. 困难的方法:打开图像作为文件,发送正确的标题,然后回显图像。 (不是一个好主意)

+0

的原因显示 - 谢谢:) – Robert

相关问题