The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
Inserting PHP code into HTML generated by a CGI/PERL script
Discuss Inserting PHP code into HTML generated by a CGI/PERL script in the PHP Development forum on Dev Shed. Inserting PHP code into HTML generated by a CGI/PERL script PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 17th, 1999, 04:11 PM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
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
|

November 18th, 1999, 09:18 AM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
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.
|

November 22nd, 1999, 03:45 PM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
The problem is that when CGI returns HTML, it still comes with CGI extension (http://www.host.com/cgi-bin/file.cgi).
|

November 23rd, 1999, 08:44 AM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
Odd.
Just rename the file.
|

December 1st, 1999, 12:28 PM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
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/
|

December 9th, 1999, 07:27 PM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
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! URL
------------------
Alan Little
Holotech Web Design
http://www.holotech.net/
|

December 10th, 1999, 08:53 AM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
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??
|

December 11th, 1999, 02:04 PM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
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~
|

December 11th, 1999, 07:39 PM
|
|
Guest
|
|
Posts: n/a
Time spent in forums:
Reputation Power:
|
|
|
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
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|