Check click

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Boris ©avc

    Check click

    I have a page and a sponsor. Every time a user click on a banner from our
    sponsor their webpage is opened. I'd like to reward these users, but how to
    check who clicked on a banner. I can't do anything on sponsor's webpage?

    Thanks for helping,
    Boris ©avc



  • Pedro Graca

    #2
    Re: Check click

    Boris ©avc wrote:[color=blue]
    > I have a page and a sponsor. Every time a user click on a banner from our
    > sponsor their webpage is opened. I'd like to reward these users, but how to
    > check who clicked on a banner. I can't do anything on sponsor's webpage?[/color]

    Instead of
    <a href="http://sponsor.com/"><img src="sponsor.pn g"/></a>

    do
    <a href="sponsor.p hp?url=http://sponsor.com/"><img src="sponsor.pn g"/></a>

    and in sponsor.php redirect to the sponsor page after updating your user
    information, for example:

    <?php //sponsor.php
    $user_id = 0; // ir your code get it from where you have it stored
    $sql = "update user set clicks=clicks+1 where id=$user_id";
    // do sql

    header('Locatio n: ' . $_GET['url']);
    // some browsers may not follow the redirect
    exit('Redirecte d <a href="' . $_GET['url'] . '">here</a>');
    ?>

    --
    USENET would be a better place if everybody read: : mail address :
    http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
    http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
    http://www.expita.com/nomime.html : to 10K bytes :

    Comment

    • FLEB

      #3
      Re: Check click

      Regarding this well-known quote, often attributed to Pedro Graca's famous
      "26 May 2004 11:10:46 GMT" speech:
      [color=blue]
      > Boris ©avc wrote:[color=green]
      >> I have a page and a sponsor. Every time a user click on a banner from our
      >> sponsor their webpage is opened. I'd like to reward these users, but how to
      >> check who clicked on a banner. I can't do anything on sponsor's webpage?[/color]
      >
      > Instead of
      > <a href="http://sponsor.com/"><img src="sponsor.pn g"/></a>
      >
      > do
      > <a href="sponsor.p hp?url=http://sponsor.com/"><img src="sponsor.pn g"/></a>
      >
      > and in sponsor.php redirect to the sponsor page after updating your user
      > information, for example:
      >
      > <?php //sponsor.php
      > $user_id = 0; // ir your code get it from where you have it stored
      > $sql = "update user set clicks=clicks+1 where id=$user_id";
      > // do sql
      >
      > header('Locatio n: ' . $_GET['url']);
      > // some browsers may not follow the redirect
      > exit('Redirecte d <a href="' . $_GET['url'] . '">here</a>');
      > ?>[/color]

      For a more robust solution, I'd recommend having some sort of table linking
      individual banners or sponsors to their sites, be it an external MySQL
      table or a simple hash array. Limiting the script to a finite number of
      approved URLs it can redirect to will stop cross-site scripting attacks and
      other illegitimate uses of your site's script.




      <?php
      // Remember! Nothing comes before the ?php tag, or the
      // redirect won't work!

      $my_home_page = "http://www.somewhereor other.com";
      $banners = array(
      "example1" => "http://www.example.com/",
      "example2" => "http://www.example.com/superwebvalues" ,
      "phpnet" => "http://www.php.net/"
      );
      // Set up a hash array with codenames => URLs
      // (See http://us3.php.net/manual/en/language.types.array.php )


      if ($banners[$_GET['banner']]) { // if the banner they requested exists...
      // (Do some MySQL or something HERE to increment the codename's counter)
      // ...

      // Then redirect to the proper page
      // (See http://us3.php.net/manual/en/function.header.php )
      header("Locatio n: " . $banners[$_GET['banner']]);
      }
      else {
      // If there isn't a banner with that codename,
      // just redirect to the homepage
      header("Locatio n: " . $my_home_page);
      }

      ?>

      --
      -- Rudy Fleminger
      -- sp@mmers.and.ev il.ones.will.bo w-down-to.us
      (put "Hey!" in the Subject line for priority processing!)
      -- http://www.pixelsaredead.com

      Comment

      • FLEB

        #4
        Re: Check click

        Regarding this well-known quote, often attributed to FLEB's famous "Wed, 26
        May 2004 15:39:20 -0400" speech:
        [color=blue]
        > Regarding this well-known quote, often attributed to Pedro Graca's famous
        > "26 May 2004 11:10:46 GMT" speech:
        >[color=green]
        >> Boris ©avc wrote:[color=darkred]
        >>> I have a page and a sponsor. Every time a user click on a banner from our
        >>> sponsor their webpage is opened. I'd like to reward these users, but how to
        >>> check who clicked on a banner. I can't do anything on sponsor's webpage?[/color][/color][/color]
        [color=blue]
        > For a more robust solution, I'd recommend having some sort of table linking
        > individual banners or sponsors to their sites, be it an external MySQL
        > table or a simple hash array. Limiting the script to a finite number of
        > approved URLs it can redirect to will stop cross-site scripting attacks and
        > other illegitimate uses of your site's script.
        >
        > http://us3.php.net/manual/en/language.types.array.php
        >
        >
        > <?php
        > // Remember! Nothing comes before the ?php tag, or the
        > // redirect won't work!
        >
        > $my_home_page = "http://www.somewhereor other.com";
        > $banners = array(
        > "example1" => "http://www.example.com/",
        > "example2" => "http://www.example.com/superwebvalues" ,
        > "phpnet" => "http://www.php.net/"
        > );
        > // Set up a hash array with codenames => URLs
        > // (See http://us3.php.net/manual/en/language.types.array.php )
        >
        >
        > if ($banners[$_GET['banner']]) { // if the banner they requested exists...
        > // (Do some MySQL or something HERE to increment the codename's counter)
        > // ...
        >
        > // Then redirect to the proper page
        > // (See http://us3.php.net/manual/en/function.header.php )
        > header("Locatio n: " . $banners[$_GET['banner']]);
        > }
        > else {
        > // If there isn't a banner with that codename,
        > // just redirect to the homepage
        > header("Locatio n: " . $my_home_page);
        > }
        >
        > ?>[/color]

        I forgot something. To use this script, assuming it's called "banner.php "
        access it as:

        banner.php?bann er=codename

        Where "codename" is the codename in the first column.

        --
        -- Rudy Fleminger
        -- sp@mmers.and.ev il.ones.will.bo w-down-to.us
        (put "Hey!" in the Subject line for priority processing!)
        -- http://www.pixelsaredead.com

        Comment

        Working...