我正在尝试跟踪是否有人(不是谁)打开了我通过PHP脚本发送的邮件,并点击了我嵌入邮件中的链接。
在邮件中准备变量:
使用将在record.php中加载的图像进行邮件点击跟踪:
<img src="http://localhost:8090/post_ch/admin/record.php?read=1" alt="Tracker">
链接点击跟踪:
<a href="http://localhost:8090/post_ch/portal/indexbab9.php?click=1">Link</a>
在数据库中插入记录
record.php用于邮件点击记录:
<?php
// (inside "record.php")
header('Content-Type: image/gif');
if(isset($_GET['read']))
{
$pdo = new PDO('SECURE (should work)');
$statement = $pdo->prepare("INSERT INTO employee_clickedmail (clickedmail) VALUES (1)");
}
//push out image
if(ini_get('zlib.output_compression')) { ini_set('zlib.output_compression', 'Off'); }
header('Pragma: public'); // required
header('Expires: 0'); // no cache
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private',false);
header('Content-Disposition: attachment; filename="blank.gif"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.filesize('blank.gif')); // provide file size
readfile('blank.gif'); // push it out
exit();
?>
AND用于链接点击:
<?php
if(isset($_GET['click']))
{
$pdo = new PDO('SECURE (should work)');
$statement = $pdo->prepare("INSERT INTO employee_clickedlink (clickedlink) VALUES (1)");
}
?>
正如您所看到的,每当有人加载图像并单击邮件中的链接时,我只想在表中插入值“1”。有谁知道这个问题?
答案 0 :(得分:2)
对于每个prepare()
语句,您需要调用execute()
以实际执行对数据库的查询。