从映像

时间:2017-05-28 19:02:54

标签: php email

我的PHP代码需要一些帮助。我想在查看隐藏图像时重定向到我的PHP脚本。

当我尝试这个时:     http://robertsite.org/phpmailer/examples/blank.jpg?http://robertsite.org/phpmailer/phpmailer/examples/send.php?id=71

它将显示图像,但不会重定向到带有ID的send.php脚本。

以下是代码:

<?php
include('config.php');
require '../PHPMailerAutoload.php';
if (isset($_POST['send'])) {
$from = 'rob@robertsite.org';
$toArr = explode(",",$_POST['to']);
$subject = $_POST['subject'];
$message = $_POST['message'];
$sendDateTime = date("Y-m-d h:i:s");


foreach($toArr as $to) 
{
mysql_query("insert into tracker(email, sendDateTime,isRead) values('$to', '$sendDateTime', '0')");
$selSendEmailID = mysql_query("select id from tracker order by id desc");
$rowSendEmailID = mysql_fetch_array($selSendEmailID);
$rowEmailID = $rowSendEmailID['id'];


$message .= "<img src=\"http://robertsite.org/phpmailer/examples/blank.jpg?http://robertsite.org/phpmailer/examples/send.php?id=".$rowEmailID."\" style=\"width:0px; min-height: 0px; height:0px;\" alt=\" \">";


   $mail = new PHPMailer;
   $mail->IsSMTP();
   $mail->Host = "mail.robertsite.org";
   $mail->SMTPDebug = 0;
   $mail->SMTPAuth = true;
   $mail->SMTPSecure = "ssl";   
   $mail->Username = 'rob@robertsite.org';
   $mail->Password = 'mypassword';
   $mail->Port = 465;  //25, 465 or 587
   $mail->FromName = 'Robert Test Mail';
   $mail->From = $from; 
   $mail->WordWrap = 50;
   $mail->isHTML(true);
   $mail->Subject = $subject;
   $mail->Body    = $message;
   $mail->addAddress($to);
   $mail->send();
}
echo "Email has been sent!";
}
?>

我正在为电子邮件跟踪器执行此操作,我可以看到是否有人阅读了我的电子邮件。我尝试使用没有blank.jpg,它将显示空图像,所以我必须使用blank.jpg显示为无法看到的空白图像。

当我查看blank.jpg图片时,你知道如何运行带有ID的send.php脚本吗?

编辑:这是send.php脚本:

<?php

include('config.php');

if($_GET['id'] != ''){
    $id = $_GET['id'];  
    $readDateTime = date("Y-m-d h:i:s");
    mysql_query("update tracker set isRead='1', readDateTime='$readDateTime' where id='$id'");
}

  if (!empty($_POST['message'])) 
  {
    $emails = explode("\n", $_POST['message']); // explode textarea on a line break into an array
    $email_str = implode(", ", $emails); // take each of the emails and implode together with the ,

    echo '<script> closePopUp(); </script>'; //call javascript function
  }  
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Send Email</title>
    <link type="text/css" rel="stylesheet" href="style.css"  />
    <script src="jquery-1.12.0.js"></script>
    <script>
        $(document).ready(function(){
            $('#popup').click(function(event) {
                event.preventDefault();

                var popup = window.open("add_address.php", "_blank", "toolbar=yes, scrollbars=yes, resizable=yes, top=100, left=500, width=400, height=400");
                if (popup != null && !popup.closed) {
                var element = popup.document.getElementById("thePopupField");
                var text = $('#theField').val();
                 if(text != ''){
                    var count = (text.match(/,/g) || []).length;
                    popup.my_count = count+1;
                    popup.my_special_setting = text.replace(/,/g, '\n');
                 }
                }

            });
        });
    </script>
    </head>
    <body>
    <!---->
    <form action="pr_send.php" method="POST" id="theForm">
    <table> 
        <!-- <tr>
            <td>From:</td>
            <td><input type="text" name="from"></td>
        </tr> -->
        <tr>
            <td><input type="button" name="to" value="" style="height:24px; width:24px; background:url('addressbook.png'); border:none;" id="popup" > To:</td> <!--onClick="Popup()"-->
            <td><input type="text" id="theField" name="to" value="<?php if (!empty($email_str)) { echo $email_str; } ?>" style="height:15px; width:650px">&nbsp;(<span id="noOfEmails">0</span>)</td>
        </tr>
        <tr>
            <td>Subject:</td>
            <td><input type="text" name="subject" style="height:15px; width:650px"></td>
        </tr>
        <tr>
            <td>Message:</td>
            <td><textarea name="message" cols="90" rows="20"></textarea></td>
        </tr>
        <tr>
            <td colspan="2" align="left">
               <input type="submit" name="send" value="" style="height:35px; width:100px; background:url('send.png'); border:none">
            </td>
        </tr>

    </table>
    </form>
    </body>
<!--<script type="text/javascript">
var popup = null;
function Popup() 
{
  window.open("add_address.php", "_blank", "toolbar=yes, scrollbars=yes, resizable=yes, top=100, left=500, width=400, height=400");
}
function closePopUp() 
{
  if (popup) 
  {
    popup.close();
  }
}

</script>-->

</html>

1 个答案:

答案 0 :(得分:0)

相反

   $message .= "<img src=\"http://robertsite.org/phpmailer/examples/blank.jpg?http://robertsite.org/phpmailer/examples/send.php?id=".$rowEmailID."\" style=\"width:0px; min-height: 0px; height:0px;\" alt=\" \">";

你必须使用

 $message .= "<img src=\"http://robertsite.org/phpmailer/examples/send.php?id=".$rowEmailID."&img=".urlencode('http://robertsite.org/phpmailer/examples/blank.jpg')."\" style=\"width:0px; min-height: 0px; height:0px;\" alt=\" \">";

在send.php脚本中添加几个字符串

if($_GET['id'] != ''){
      $id = (int)$_GET['id'];  
      $readDateTime = date("Y-m-d h:i:s");
      mysql_query("update tracker set isRead='1', readDateTime='$readDateTime' where id='$id'");
      if(!empty($_GET['img'])) {
           header('location: '.$_GET['img']);
           exit;
      }
}
相关问题