PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 17th, 1999, 04:11 PM
pandemus
Guest
Dev Shed Newbie (0 - 499 posts)
 
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

Reply With Quote
  #2  
Old November 18th, 1999, 09:18 AM
rod k
Guest
Dev Shed Newbie (0 - 499 posts)
 
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.

Reply With Quote
  #3  
Old November 22nd, 1999, 03:45 PM
pandemus
Guest
Dev Shed Newbie (0 - 499 posts)
 
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).

Reply With Quote
  #4  
Old November 23rd, 1999, 08:44 AM
rod k
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Odd.

Just rename the file.

Reply With Quote
  #5  
Old December 1st, 1999, 12:28 PM
SJONdaMON
Guest
Dev Shed Newbie (0 - 499 posts)
 
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/

Reply With Quote
  #6  
Old December 9th, 1999, 07:27 PM
Darguz
Guest
Dev Shed Newbie (0 - 499 posts)
 
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/



Reply With Quote
  #7  
Old December 10th, 1999, 08:53 AM
rod k
Guest
Dev Shed Newbie (0 - 499 posts)
 
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??

Reply With Quote
  #8  
Old December 11th, 1999, 02:04 PM
martin83
Guest
Dev Shed Newbie (0 - 499 posts)
 
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~

Reply With Quote
  #9  
Old December 11th, 1999, 07:39 PM
inofocio
Guest
Dev Shed Newbie (0 - 499 posts)
 
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Inserting PHP code into HTML generated by a CGI/PERL script

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap