#1
  1. No Profile Picture
    pandemus
    Guest
    Devshed Newbie (0 - 499 posts)
    Is there a way to have PHP code included into HTML generated by a CGI/PERL script? The problem is that the CGI-generated HTML can not be interpreted/parsed by PHP. Unless you know how.

    Thanks
  2. #2
  3. No Profile Picture
    rod k
    Guest
    Devshed Newbie (0 - 499 posts)
    I don't know what you mean by the second sentence. PHP doesn't parse HTML, the browser does that.

    All you have to do is output the PHP code with the HTML and make sure that the file has the appropriate extension so that it gets parsed by PHP when it's accessed (probably .phtml or .php3) instead of going directly to the client as with .htm or .html.

    I'm not sure why you think this isn't possible. Have you tried it? If you have and it hasn't worked describe in detail what you did and what went wrong.
  4. #3
  5. No Profile Picture
    pandemus
    Guest
    Devshed Newbie (0 - 499 posts)
    The problem is that when CGI returns HTML, it still comes with CGI extension (http://www.host.com/cgi-bin/file.cgi).
  6. #4
  7. No Profile Picture
    rod k
    Guest
    Devshed Newbie (0 - 499 posts)
    Odd.

    Just rename the file.
  8. #5
  9. No Profile Picture
    SJONdaMON
    Guest
    Devshed Newbie (0 - 499 posts)
    It depends in wich way you output the html...
    If you want the cgi-script to generate pages on your server, just write the php-code in it, like this: (FILE is a handler to the file you want to create on your server..)

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    print FILE<<EOM;
    <?PHP
    $page_id = "2054";
    require("phpinc/common.php");
    showHeader();
    ?>

    blabla and some more...

    <?
    showFooter();
    ?>
    EOM
    [/quote]

    on the other hand, if somebody does a get-query on one of your cgi-scripts, it's not possible...

    ------------------
    Have Fun !

    SJONdaMON
    http://www.sjondamon.org/
  10. #6
  11. No Profile Picture
    Darguz
    Guest
    Devshed Newbie (0 - 499 posts)
    If I understand correctly, you're trying to output PHP code from a Perl script, and have it execute right then? This is not possible.

    Then again, now that I think about it, it might actually be possible, but how to do it is beyond me.

    Let me explain. In the normal course of events, you write a PHP script and place it in a file with an extension of PHP3 or PHTML, depending on what version you're using. When someone requests this file, the web server sees this extension and, rather than outputting it directly to the visitor, passes it to the PHP parser, which executes any PHP code in the file and *then* outputs it to the visitor.

    The same thing essentially happens with your Perl script -- the web server passes it to the Perl parser for processing, rather than outputting it directly to the visitor. Anything output by your Perl script then goes directly to the visitor -- including any PHP code. Since the PHP parser never gets called, there's nothing to parse the PHP code.

    *However*

    If you could have your Perl script call the PHP parser and pipe its output there, you might get somewhere. I don't know if/how you would do that, though.

    Or *why* for that matter!

    ------------------
    Alan Little
    Holotech Web Design
    http://www.holotech.net/


  12. #7
  13. No Profile Picture
    rod k
    Guest
    Devshed Newbie (0 - 499 posts)
    Ahhh. I didn't read into it that he wanted immediate execution. After printing to the file as SJONdaMON describes, you can redirect to that file using a header. I still don't understand why you say it isn't possible to set the extension on the file??
  14. #8
  15. No Profile Picture
    martin83
    Guest
    Devshed Newbie (0 - 499 posts)
    What about calling the cgi script with vars from within a php3 file?

    map:

    (initial.php3) <--- user-data entry
    |
    (second.php3) <--- include /cgi-bin/script.cgi?VARS


    ------------------
    __________________
    ~the brain dump~
  16. #9
  17. No Profile Picture
    inofocio
    Guest
    Devshed Newbie (0 - 499 posts)
    An easy way 'round is to call the cgi script by http, and not the local server path, like this:

    <?

    include "http://www.host.moc/cgi-bin/myfile.cgi"

    ?>


    ------------------
    -------------
    http://www.nytt.no

Similar Threads

  1. How to write a PHP script to remove a file?
    By xmxpcom in forum PHP Development
    Replies: 2
    Last Post: February 16th, 2004, 05:58 PM
  2. How to see the Memory used by a PHP script?
    By Pardall in forum PHP Development
    Replies: 4
    Last Post: February 13th, 2004, 03:54 PM
  3. php script to change pop3 password?
    By jensm in forum PHP Development
    Replies: 0
    Last Post: February 13th, 2004, 02:45 PM
  4. shedule php script
    By almedo in forum PHP Development
    Replies: 5
    Last Post: February 11th, 2004, 01:54 PM
  5. Replies: 0
    Last Post: February 8th, 2004, 10:11 PM

IMN logo majestic logo threadwatch logo seochat tools logo