Professional Web Applications Themes

want to use php to alternate links - PHP Development

Hi, I'm really really new to php. I need a push in the right direction, to take it from there, hopefully. The more detail you can give, the better. Here's what I want to do : 1. Throughout all my *.html pages replace a certain link to (e.g.) link.php?p=2 so replace the actual link to a link which is "provided" by the php code. How exactly would I do that ? 2 In the php code I would also like to take counters in account, on daily basis. For instance, if a counter is incremented to 5, then this link ...

Sponsored Links
  1. #1

    Default want to use php to alternate links

    Hi,

    I'm really really new to php.
    I need a push in the right direction, to take it from there, hopefully.
    The more detail you can give, the better.

    Here's what I want to do :

    1.
    Throughout all my *.html pages replace a certain link to (e.g.) link.php?p=2
    so replace the actual link to a link which is "provided" by the php code.

    How exactly would I do that ?

    2
    In the php code I would also like to take counters in account, on daily
    basis.
    For instance, if a counter is incremented to 5, then this link has done its
    work, now use another link to another domain etc.
    So, the counters would need to be reset somehow on daily basis.
    The idea is to have no human interaction anymore after the stuff is active.

    Here too I have no clue how to start


    Your help appreciated.


    Sponsored Links
    Peter Guest

  2. #2

    Default Re: want to use php to alternate links

    "Peter Van Hove" <net> wrote
    in message news:6gCne.108188$%telenet-ops.be...
     
    link.php?p=2 

    The *.html is static right? Therefore, you have to make these pages function
    dynamically which, ISTM, can only be done by 1) manually changing all pages,
    2) devising a way to automatically generate new *.html files, or 3)
    converting these files in question to *.php files

    From what I understand, #3 is your only option because you're going to have
    to use an "if" or "switch-case" statement to determine which links you'd
    like to display.
     
    its 
    active.

    Mechanically, this is not a difficult problem once you get some momentum
    going. The difficulty here is determining where your days break assuming
    that you may have people all over the world looking at your site.

    Include this counter and link logic on each *.php page with alternating
    links.

    Do you need a push on how to actually code this. If so, are you wanting to
    store count data in cookies/sessions or in a database?


    James Guest

  3. #3

    Default Re: want to use php to alternate links


    1.
    Static yes. Understood. Changing everything is not an option right now
    because I need the same page-names and extensions for
    link-from-outside-purposes.
    If I change them to php all the links to these pages will be lost.

    So what do you think about this :

    Because I only want to use this mechanism to links going out, not to pages
    on the same domain (no relative links), and I think I will launch them all
    in a new browser window (so not inside an existing frame or anything), ...
    Wouldn't it be a good idea to simply launch the page each time from one .php
    page, depending on the input the page gets (the 'p' variable).
    So, in the html the out-going link would in fact be a relative link to
    "link.php" but with a variable, e.g p=2 and also in the html I would need to
    make sure the link is launched in a new brower window, and then the link.php
    page would do the actual replacing of the file on the remote server ?

    Does this make sense ? I tink I can get that to work but then I need to
    know how in the "link.php" page I load the content of another page.

    2. When the day starts is not a problem, can be CET, UST, PDT, MDT, CDT,
    EDT, ... whatever, as long as it's consistent.
     [/ref]
    > store count data in cookies/sessions or in a database?[/ref]

    I have no clue how to start. It should be server side entirely, so no
    cookies but databases scare me senseless, I have NO idea how to go about
    that, set it up or ...
    For all I care it's simply stored in a txt file on the server somewhere, but
    you tell me what's best ?

    -------------------------------------------------------
    "James David" <ixx> wrote in message
    news:2ECne.90623$tampabay.rr.com... 
    > link.php?p=2 
    >
    > The *.html is static right? Therefore, you have to make these pages
    > function
    > dynamically which, ISTM, can only be done by 1) manually changing all
    > pages,
    > 2) devising a way to automatically generate new *.html files, or 3)
    > converting these files in question to *.php files
    >
    > From what I understand, #3 is your only option because you're going to
    > have
    > to use an "if" or "switch-case" statement to determine which links you'd
    > like to display.

    > its 
    > active.
    >
    > Mechanically, this is not a difficult problem once you get some momentum
    > going. The difficulty here is determining where your days break assuming
    > that you may have people all over the world looking at your site.
    >
    > Include this counter and link logic on each *.php page with alternating
    > links.
    >
    > Do you need a push on how to actually code this. If so, are you wanting to
    > store count data in cookies/sessions or in a database?
    >
    >[/ref]


    Peter Guest

  4. #4

    Default Re: want to use php to alternate links

    Peter Van Hove wrote: 

    How about still changing them and handling 404 error with php?

    Here is the trick for Apache:

    #file /home/user/public_html/.htaccess
    ErrorDoent 404 /404.php

    #file /home/user/public_html/404.php
    <?
    $www = $_SERVER['DOENT_ROOT'];
    $path = dirname($_SERVER['REQUEST_URI']);
    $file = basename($_SERVER['REQUEST_URI'], '.html');

    if (file_exists($www.$path.$file.'html'))
    {
    header('HTTP/1.1 301 Moved Permanently');
    header("Location: http://{$_SERVER['HTTP_HOST']}{$path}{$file}.php");
    }
    else
    header("HTTP/1.0 404 Not Found");

    ?>

    Didn't test it, but you'll get the idea anyway :)


    -veikko

    --
    veikko
    mail .com
    makinen
    Veikko Guest

  5. #5

    Default Re: want to use php to alternate links

    interesting !
    Maybe I will do this in a second stage !

    -------------------------------------------------------
    "Veikko Mäkinen" <signature.because.this.address.is.invalid> wrote
    in message news:_3Fne.1859$news.jippii.net... 
    >
    > How about still changing them and handling 404 error with php?
    >
    > Here is the trick for Apache:
    >
    > #file /home/user/public_html/.htaccess
    > ErrorDoent 404 /404.php
    >
    > #file /home/user/public_html/404.php
    > <?
    > $www = $_SERVER['DOENT_ROOT'];
    > $path = dirname($_SERVER['REQUEST_URI']);
    > $file = basename($_SERVER['REQUEST_URI'], '.html');
    >
    > if (file_exists($www.$path.$file.'html'))
    > {
    > header('HTTP/1.1 301 Moved Permanently');
    > header("Location: http://{$_SERVER['HTTP_HOST']}{$path}{$file}.php");
    > }
    > else
    > header("HTTP/1.0 404 Not Found");
    >
    > ?>
    >
    > Didn't test it, but you'll get the idea anyway :)
    >
    >
    > -veikko
    >
    > --
    > veikko
    > mail .com
    > makinen[/ref]


    Peter Guest

  6. #6

    Default Re: want to use php to alternate links

    I magaged to get something working here in a test setup.
    I do what I explained. From .html I load a .php page (_blank) on an
    hyperlink click

    The .php script then loads the new page this way (after deciding on the
    $newurl) :
    You'll see three ways, first the java attempt, then the refresh attempt and
    finally a click by the user if previous failed.

    Somehow of course I feel that this is overhead.
    It would be nice if via php I could do something similar, meaning load new
    content in the page.


    <html>

    <script type="text/javascript">
    self.location.replace("<?php echo $newurl ?>");
    </script>

    <head>
    <meta http-equiv="refresh" CONTENT="1;url=<?php echo $newurl ?>">
    <title>blablabla ... </title>
    <meta http-equiv="Content-Type" content="text/html;
    cht=iso-8859-1"></head>

    <body bgcolor="#FBFBFF" link="#0000CC" vlink="#0000CC" alink="#0000CC"
    text="#0000CC">
    <p align="center"><font color="#0000CC" face="Arial, Helvetica,
    sans-serif"><big><strong><br>
    </strong><font size="2">Your browser will automatically link to <a
    href="<?php echo $newurl ?>">the
    new page</a></font></big></font></p>

    </body>

    </html>


    Peter Guest

  7. #7

    Default Re: want to use php to alternate links

    Now what I still need is the counter functionlity I explained earlier,
    $newurl must (partially) also rely on a counter. E.g. change after 5 clicks
    or ...



    -------------------------------------------------------
    "Peter Van Hove" <net> wrote
    in message news:EtFne.108319$telenet-ops.be... 


    Peter Guest

  8. #8

    Default Re: want to use php to alternate links

    the 404 error page appears to be a shtml page in my provider's setup (via
    Cpanel, if that means anything ?)


    Peter Guest

Similar Threads

  1. asp alternate row color
    By Russ in forum Dreamweaver AppDev
    Replies: 2
    Last Post: April 26th, 03:18 AM
  2. Alternate db location
    By rwhart@mchsi.com in forum PostgreSQL / PGSQL
    Replies: 3
    Last Post: February 15th, 04:52 PM
  3. Using alternate web servers
    By Nida Farid in forum ASP.NET Web Services
    Replies: 1
    Last Post: August 23rd, 12:05 AM
  4. When we move Image Links and HTML links
    By Gil in forum HTML & CSS
    Replies: 0
    Last Post: July 29th, 03:12 PM
  5. ?Hard links, Soft links, & Aliases--Explain
    By Fred Moore in forum Mac Applications & Software
    Replies: 5
    Last Post: July 2nd, 02:33 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139