newbie: writing "includes" in HTML

Discussion in 'HTML' started by Dan Blather, Jul 9, 2005.

  1. Dan Blather

    Dan Blather Guest

    Hi,

    i'm useing 2 servers to host my site, one is a "backup" in case the other
    fails, or to handle overflow bandwidth.
    I want to create a little ID tag to implant at the bottom of my home page to
    let me know which server I am logging in to with my browser.

    i thought that using php or javascript i could create a simple little
    "document.write" statment, ID'ing the server that I could call from the
    bottom of the web-page, either with a simple <script src ...> javascript
    tag. I tried it with Javascript, but I got a bizarre message "code
    corrupted. Insert fresh copy" written into the bottom of the web page (which
    I have NEVER gotten using Javascript before, usually the browser debugger
    does the reporting!)

    if anyone could coach me on how to use a simple PHP include statement (i
    assume i could hide the php statement with the server ID tag in my
    cgi-bin?), I would certainly appreciate it...

    thanks,

    Phil
     
    Dan Blather, Jul 9, 2005
    #1
    1. Advertising

  2. Dan Blather

    Adrienne Guest

    Gazing into my crystal ball I observed "Dan Blather" <>
    writing in news:5_Eze.124645$tt5.96061@edtnps90:

    > Hi,
    >
    > i'm useing 2 servers to host my site, one is a "backup" in case the
    > other fails, or to handle overflow bandwidth.
    > I want to create a little ID tag to implant at the bottom of my home
    > page to let me know which server I am logging in to with my browser.
    >
    > i thought that using php or javascript i could create a simple little
    > "document.write" statment, ID'ing the server that I could call from the
    > bottom of the web-page, either with a simple <script src ...>
    > javascript tag. I tried it with Javascript, but I got a bizarre
    > message "code corrupted. Insert fresh copy" written into the bottom of
    > the web page (which I have NEVER gotten using Javascript before,
    > usually the browser debugger does the reporting!)


    You actually want server side, not client side, and you want to look at the
    server collection, specifically SERVER_NAME.

    <?php echo $_SERVER["SERVER_NAME"] ?>

    --
    Adrienne Boswell
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
     
    Adrienne, Jul 9, 2005
    #2
    1. Advertising

  3. Dan Blather

    Mark Guest

    Adrienne wrote:
    > Gazing into my crystal ball I observed "Dan Blather" <>
    > writing in news:5_Eze.124645$tt5.96061@edtnps90:
    >
    >
    >>Hi,
    >>
    >>i'm useing 2 servers to host my site, one is a "backup" in case the
    >>other fails, or to handle overflow bandwidth.
    >>I want to create a little ID tag to implant at the bottom of my home
    >>page to let me know which server I am logging in to with my browser.
    >>
    >>i thought that using php or javascript i could create a simple little
    >>"document.write" statment, ID'ing the server that I could call from the
    >>bottom of the web-page, either with a simple <script src ...>
    >>javascript tag. I tried it with Javascript, but I got a bizarre
    >>message "code corrupted. Insert fresh copy" written into the bottom of
    >>the web page (which I have NEVER gotten using Javascript before,
    >>usually the browser debugger does the reporting!)

    >
    >
    > You actually want server side, not client side, and you want to look at the
    > server collection, specifically SERVER_NAME.
    >
    > <?php echo $_SERVER["SERVER_NAME"] ?>
    >

    Alternatively, you might add the following SSI statment:

    <p style="color: white;">IP: <!--#echo var="SERVER_ADDR" --></p>

    This will echo the IP address of the server. I have placed it inside a
    white paragraph to sort of hide it (but not very well: you can still
    select it and see what it says).

    SSI is not necessarily enabled on your server, and usually, though not
    always, requires you to change your page's extension from .html to
    ..shtml to signal to the server that it may need to do something with the
    page.

    Mark
     
    Mark, Jul 9, 2005
    #3
  4. Dan Blather

    Dan Blather Guest

    thanks for the replies. i tried Adrienne's solution (had to rename the
    extension ".php") ... and all I got was my domain name, but nothing to
    uniquely ID the server (same domain is hosted on 2 servers).

    Tried Mark's alternative and only got "IP:" in white, same when I used the
    ".php" extension.

    Phil


    "Mark" <> wrote in message
    news:QDPze.23560$...
    > Adrienne wrote:
    >> Gazing into my crystal ball I observed "Dan Blather" <>
    >> writing in news:5_Eze.124645$tt5.96061@edtnps90:
    >>>Hi,
    >>>
    >>>i'm useing 2 servers to host my site, one is a "backup" in case the
    >>>other fails, or to handle overflow bandwidth.
    >>>I want to create a little ID tag to implant at the bottom of my home
    >>>page to let me know which server I am logging in to with my browser.
    >>>
    >>>i thought that using php or javascript i could create a simple little
    >>>"document.write" statment, ID'ing the server that I could call from the
    >>>bottom of the web-page, either with a simple <script src ...>
    >>>javascript tag. I tried it with Javascript, but I got a bizarre
    >>>message "code corrupted. Insert fresh copy" written into the bottom of
    >>>the web page (which I have NEVER gotten using Javascript before,
    >>>usually the browser debugger does the reporting!)

    >>
    >>
    >> You actually want server side, not client side, and you want to look at
    >> the server collection, specifically SERVER_NAME.
    >>
    >> <?php echo $_SERVER["SERVER_NAME"] ?>
    >>

    > Alternatively, you might add the following SSI statment:
    >
    > <p style="color: white;">IP: <!--#echo var="SERVER_ADDR" --></p>
    >
    > This will echo the IP address of the server. I have placed it inside a
    > white paragraph to sort of hide it (but not very well: you can still
    > select it and see what it says).
    >
    > SSI is not necessarily enabled on your server, and usually, though not
    > always, requires you to change your page's extension from .html to .shtml
    > to signal to the server that it may need to do something with the page.
    >
    > Mark
     
    Dan Blather, Jul 9, 2005
    #4
  5. Dan Blather

    Els Guest

    Dan Blather wrote:

    > thanks for the replies. i tried Adrienne's solution (had to rename the
    > extension ".php") ... and all I got was my domain name, but nothing to
    > uniquely ID the server (same domain is hosted on 2 servers).
    >
    > Tried Mark's alternative and only got "IP:" in white, same when I used the
    > ".php" extension.


    Well, combine the two ;-)

    <?php echo $_SERVER["SERVER_ADDR"] ?>

    Should return the IP address.
    (needs .php extension)

    --
    Els http://locusmeus.com/
    Sonhos vem. Sonhos vão. O resto é imperfeito.
    - Renato Russo -
    Now playing: Etta James - I Just Want To Make Love To You
     
    Els, Jul 9, 2005
    #5
  6. Dan Blather

    Mark Guest

    Dan Blather wrote:
    > thanks for the replies. i tried Adrienne's solution (had to rename the
    > extension ".php") ... and all I got was my domain name, but nothing to
    > uniquely ID the server (same domain is hosted on 2 servers).
    >
    > Tried Mark's alternative and only got "IP:" in white, same when I used the
    > ".php" extension.
    >
    > Phil
    >
    >
    > "Mark" <> wrote in message
    > news:QDPze.23560$...
    >
    >>Adrienne wrote:
    >>
    >>>Gazing into my crystal ball I observed "Dan Blather" <>
    >>>writing in news:5_Eze.124645$tt5.96061@edtnps90:
    >>>
    >>>>Hi,
    >>>>
    >>>>i'm useing 2 servers to host my site, one is a "backup" in case the
    >>>>other fails, or to handle overflow bandwidth.
    >>>>I want to create a little ID tag to implant at the bottom of my home
    >>>>page to let me know which server I am logging in to with my browser.
    >>>>
    >>>>i thought that using php or javascript i could create a simple little
    >>>>"document.write" statment, ID'ing the server that I could call from the
    >>>>bottom of the web-page, either with a simple <script src ...>
    >>>>javascript tag. I tried it with Javascript, but I got a bizarre
    >>>>message "code corrupted. Insert fresh copy" written into the bottom of
    >>>>the web page (which I have NEVER gotten using Javascript before,
    >>>>usually the browser debugger does the reporting!)
    >>>
    >>>
    >>>You actually want server side, not client side, and you want to look at
    >>>the server collection, specifically SERVER_NAME.
    >>>
    >>><?php echo $_SERVER["SERVER_NAME"] ?>
    >>>

    >>Alternatively, you might add the following SSI statment:
    >>
    >><p style="color: white;">IP: <!--#echo var="SERVER_ADDR" --></p>
    >>
    >>This will echo the IP address of the server. I have placed it inside a
    >>white paragraph to sort of hide it (but not very well: you can still
    >>select it and see what it says).
    >>
    >>SSI is not necessarily enabled on your server, and usually, though not
    >>always, requires you to change your page's extension from .html to .shtml
    >>to signal to the server that it may need to do something with the page.
    >>
    >>Mark

    >
    >
    >

    Try this

    SSI Solution:

    Make sure that SSI is enabled on your server.
    Name your file something.shtml
    <p>IP: <!--#echo var="SERVER_ADDR" --></p>

    PHP Solution:

    Name your file something.php
    <?php
    $ip = gethostbyname ($SERVER_NAME);
    ?>
    ...
    <p>IP: <?php print "$ip"; ?></p>

    If that still doesn't work, what server/platform are you running? Is it
    configured to do the above, or at least, can you configure it?

    Mark
     
    Mark, Jul 10, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?am9obno=?=

    Downloading File Includes HTML ???

    =?Utf-8?B?am9obno=?=, Feb 27, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    581
    bruce barker
    Feb 27, 2004
  2. William F. Zachmann
    Replies:
    6
    Views:
    2,638
    William F. Zachmann
    Oct 25, 2005
  3. bronski
    Replies:
    0
    Views:
    454
    bronski
    Feb 16, 2005
  4. Ed
    Replies:
    38
    Views:
    1,351
  5. Satabdi Mukherjee
    Replies:
    1
    Views:
    579
    Terry Jan Reedy
    Apr 4, 2013
Loading...

Share This Page