2017-05-28 12 views
0

PHPコードの助けが必要です。私は隠し画像を見るときに私の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 = '[email protected]'; 
$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 = '[email protected]'; 
    $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> 
+0

私はあなたのsend.phpに 'を持っていて、そのメールを送った後にblank.jpgにリダイレクトしています。 – rickdenhaan

+0

@rickdenhaanご協力いただきありがとうございます。私はsend.phpを使って電子メールを書いて送信する方法と、send.phpを使って画像を見る方法を教えてください。 –

+0

'mysql_query()'の後に 'tracker'テーブルを更新するには' header( 'Location:/path/to/blank.jpg') 'を使ってユーザを画像にリダイレクトします。 **サイドノート**:あなたは本当に新しいコードでmysql_ *関数を使うべきではありません。これらのクエリはSQLインジェクション攻撃の影響を受けやすいのです。 'mysqli'や' PDO'を見て、準備されたステートメントの使い方を読んでください。 – rickdenhaan

答えて

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; 
     } 
} 
関連する問題