CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: How to have some HTML generated on the fly by CGI?

  1. #1
    Join Date
    Jul 2005
    Posts
    185

    How to have some HTML generated on the fly by CGI?

    Hi!

    First of all I wasn't sure if it's a server-side problem or a client-side problem so please forgive me if I made a mistake!

    I can create a CGI that will send any kind of data (I'm a programmer).
    The thing is, I want my CGI to be able to do this:
    If a client has a webpage, what should he insert into the source of the page (it's a simple HTML file) that will make a contact to my CGI and then get an image plus a link?

    To make it clear:
    The client has this code in his HTML file:
    HTML Code:
     
    <html>
    <head>
    <title>Untitled Document</title>
    </head>
    <body>
    ***** here I want something that will connect my CGI in 'http://somewhere.com/cgi-bin/cg' and this line will be replaced with an HTML code that displays an image and has a link *****
    </body>
    </html>
     
    The target is to be able to let other webpage owners put some kind of a code inside their HTML and that will connect my server. Then my server will send them some HTML code to be placed where their code is.

    So what should I do? Can it be solved with HTML or any kind of scripting like JavaScript/VBScript ?

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,943

    Re: How to have some HTML generated on the fly by CGI?

    PHP has an include function. Does not CGI also?

    If you want a client-side solution, take a look at Spymac's way of doing it.

    Code:
    <script language=javascript>
    if(window == window.top) {
    var address=window.location;
    var s=''+''+
    '<frameset rows=138,* frameborder=0 border=0 framespacing=0 onload=return true; onunload=return true;>'+
    '<frame src=http://www.spymac.com/webmanager/frame.php name=SpymacAdFrame  marginwidth=0 marginheight=0 scrolling=no noresize>'+
    '<frame src='+address+'? name=memberPage marginwidth=0 marginheight=0 scrolling=auto noresize>'+
    '</frameset>'+
    '';
    document.write(s);
    }
    </script>
    	    <html>
    <title>PeejAvery</title>
    <body topmargin=10 leftmargin=10 rightmargin=10 bottommargin=10 marginwidth=10 marginheight=10>
    <table border=0 width=100% height=33%><tr><td align="center" valign="bottom">
    <font face="arial" size=6 color="#000000"><b>Coming soon!</b></font>
    </td></tr></table>
    <script language="JavaScript">
      location.replace('http://peejavery.1500mb.com');
    </script>
    </body>
    </html>
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Jul 2005
    Posts
    185

    Re: How to have some HTML generated on the fly by CGI?

    Can you please highlight what I need coz to me it just redirects the page..

    PS: Any other solution? A one without the need of a frame would be even better ! Something like a "real" #include where I can inject pure HTML from another URL, without the need for another frame.. ??

  4. #4
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,943

    Re: How to have some HTML generated on the fly by CGI?

    The frame was just a client-side solution. Truly you will have to use includes to make it right. Just make a simple includes statement and give them the path to your script.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5
    Join Date
    Jul 2005
    Posts
    185

    Re: How to have some HTML generated on the fly by CGI?

    Can you post an example, sir?

  6. #6
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,943

    Re: How to have some HTML generated on the fly by CGI?

    Wherever you put the include, is where it will insert the other file. I don't work with CGI but I think it has an include statement. I would have to give you a PHP example because I don't know CGI.

    index.php
    PHP Code:
    <html>
      <head>
        <title>Title here!</title>
      </head>
    <body>
    <?php include 'inc_table.php'?>
    </body>
    </html>
    inc_table.php
    PHP Code:
    <table>
      <
    tr>
        <
    td>A</td>
        <
    td>B</td>
        <
    td>C</td>
      </
    tr>
      <
    tr>
        <
    td>1</td>
        <
    td>2</td>
        <
    td>3</td>
      </
    tr>
    </
    table
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  7. #7
    Join Date
    Jul 2005
    Posts
    185

    Re: How to have some HTML generated on the fly by CGI?

    Thanks !

  8. #8
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,943

    Re: How to have some HTML generated on the fly by CGI?

    You're welcome. Good luck.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)