image - img tag html run php function automatically without trigger it
I created a tracking function which is used to track if user open email that i sent by using img tag.
The code is like below:
<img src="' . $domain . "/a/Specialopenemail.php?&p=" .$message_id . "&m=" . $memberid .'" width="1" height="1" />
It works fine for the first time, but after several times sending emails, the img triggered automatically and assumed all the users already open the email eventhough they not opened it.
I try using clear cache and sleep function but it doesn't seem to work. I searched over the internet but till now the method of track email is still the same.
Answer
Solution:
If the image is caching, and therefore loading in the email but not making a call to the server, add a timestamp to the URL to make every email image unique:
<?php
$img_tag = '<img src="' . $domain . '/a/Specialopenemail.php'
. '?p=' . $message_id . '&m=' . $memberid
. '&ts=' . time() . '" width="1" height="1" />';
?>
$img_tag
looks something like:
<img src="http://example.com/a/Specialopenemail.php?p=324&m=27&ts=1667494626" width="1" height="1" />
1667494626
is an example what is returned by .
time()
returns:
Source...seconds since the Unix epoch (January 1 1970 00:00:00 GMT).