Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

using a graphic to invoke a php script?

Options
  • 09-01-2003 5:50pm
    #1
    Registered Users Posts: 6,315 ✭✭✭


    Is it possible to use a graphic to invoke a php script?

    i.e. <img src "logo.gif> displays logo.gif but also calls the script logo.gif.php or something like that.

    Trying to put a graphic in my mailing list which increments a counter each time the image is loaded.

    Trying to see how many of my subscribers read the newsletter and how many bin it.


Comments

  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    I'm sure you can, but it's a tad difficult, depending on what browser/email client they're using. Some email clients support scripts, some don't. Some open up a browser to display HTML messages, others show them in the client window.

    IMO, the easiest way to do it, is to stick a link at the top of the newsletter, saying, "I'm trying to get a figure on the amount of active users, please click this link - no ads or popups", and have a link to a tiny script, which simply prints out, "Thank you, you have been counted" - and include the person's email address in the referring link.

    That's just my 2 cents on the issue :)


  • Registered Users Posts: 6,315 ✭✭✭ballooba


    Had a better look at the PHP manual on PHP.NET and found a whole host of image functions. (i.e. a whole chapter, *me kicks myself*).

    Unfortunately the version of php run on my server does not support these functions which is a bit of a pain.

    I could ask my SP to install it on the server but it just seems like more hassle than its worth.

    I wan't to get an exact figure and i don't espect everyone will click the link of there own accord.

    Thanks for replying anyway.


  • Closed Accounts Posts: 304 ✭✭Zaltais


    What you can do is have a php script output an image....

    so in your newsletter you put your image in as:

    <img src="http://www.yourhost.com/counter.php&quot; border="0">

    which does all your counter stuff and then spits an image out to the end user...

    Most hosts AFAIK provide the GD library which is needed to manipulate images and you should be able to find an example of how to create images online, there's probably one at

    http://www.php.net/manual/en/ref.image.php

    And i'm sure a bit of a google may help


  • Closed Accounts Posts: 304 ✭✭Zaltais


    Just read your response, you could try opening a gif in Notepad and changing the header in your php script then printing the contents of the .gif file....

    No idea if it'll work though....


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    A PHP script that outputs the image's binary data with the correct headers (Content-Type and Content-Disposition, principally) while updating your counter would do the trick. Just call it as you would a normal image file.


  • Advertisement
  • Registered Users Posts: 6,315 ✭✭✭ballooba


    End Solution was ::

    /*<?
    $counter = "logo_counter.ctr";
    $fd = fopen($counter, "r");
    $num = fread($fd, filesize( $counter ));
    fclose($fd);

    $fd = fopen($counter, "w");
    $users = $num;
    $users++;
    fwrite($fd, $users);
    fclose($fd);

    show_image();

    function show_image()
    {
    header("Content-type: image/jpeg");
    $im = imagecreatefromjpeg("student_logo.jpeg");
    imagejpeg($im);
    imagedestroy($im);
    }
    ?>*/


    Thanks all. I checked my server config. GD was enabled (with jpeg support.. which is not standard?).


Advertisement