Web Analytics Made Easy -
StatCounter Looking for a spinner that can spin between 10 different links - CodingForum

Announcement

Collapse
No announcement yet.

Looking for a spinner that can spin between 10 different links

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Looking for a spinner that can spin between 10 different links

    I'm looking for a spinner, coded in whatever language, preferrably PHP.

    When visitors come to my website, I want them to be randomly redirected from a choice of 10 different links.

    For example.

    Visitor #1 goes to http://mysite.com/page.php and lands on http://google.com
    Visitor #2 goes to http://mysite.com/page.php and lands on http://twitter.com
    etc.... etc...

    Thanks.

  • #2
    There are other decisions to make ...
    1) Will they redirect immediately, or be asked?
    2) Will the other site open in a new window/tab, or in replacement of current browser.
    3) What if the person visits (back arrow) your site over and over. Does it go randomly,
    or stay on the same site until they close their browser and come back?
    4) Describe why you are doing this, will this benefit your site somehow? Why would
    anyone want this to happen when they visit your site?


    .

    Comment


    • #3
      Originally posted by mlseim View Post
      There are other decisions to make ...
      1) Will they redirect immediately, or be asked?
      2) Will the other site open in a new window/tab, or in replacement of current browser.
      3) What if the person visits (back arrow) your site over and over. Does it go randomly,
      or stay on the same site until they close their browser and come back?
      4) Describe why you are doing this, will this benefit your site somehow? Why would
      anyone want this to happen when they visit your site?


      .
      1.) Immediately
      2.) In replacement of current browser
      3.) That part does not matter
      4.) I'm trying to spin between different website content on my site. Not necessarily external sites.

      Comment


      • #4
        Create a plain text file called "spin.txt" ...
        Make it look like this (each link on its own line):

        Title of site 1|http://www.google.com|photo1.jpg
        Title of site 2|http://www.yahoo.com|photo2.jpg

        etc.

        My example shows both ways ...
        An immediate redirect, or display the random link for the user.

        As many links as you want, and add as many fields as you want ...
        like a title, the link itself, maybe a graphic image?

        Separate each one by pipes |

        Save it as something like "spin.txt" and use PHP to redirect randomly.

        This appears at the top of your PHP script ... possibly "index.php"?

        PHP Code:
        <?php
        // open the list of links and put into an array.
        $spin=file("spin.txt");

        // randomize (shuffle) the array.
        shuffle($spin);

        // Put the various fields into variable names you wish.
        $fields=explode("|",$spin[0]);
        $title=$fields[0];
        $url=$fields[1];
        $image=$fields[2];

        // if you want to redirect without displaying your HTML page, uncomment this line:
        // header ("location: $url");

        // if you would rather display the random link instead of redirecting ...
        // in your HTML below, you will be able to display it however you want.

        // the rest of your HTML page appears below, after this script.
        ?>

        <html>
        <title> My Site </title>

        <body>

        If you wish to display the link instead of redirecting ....
        <a href="<?=$url?>"><?=$title?></a>

        <body>
        </html>


        .

        Comment


        • #5
          thanks Mlseim it's working for my links

          regards,
          Jhon

          Comment

          Working...
          X
          😀
          🥰
          🤢
          😎
          😡
          👍
          👎