Calling a CGI in PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
oldtimer
Forum Contributor
Posts: 204
Joined: Sun Nov 03, 2002 8:21 pm
Location: Washington State

Calling a CGI in PHP

Post by oldtimer »

I have a cgi script that I want to run inside a php page. But I do not want to have to use a post form. I just want to do like an include type of thing and let the cgi script do its thing and then print back that information onto the php page.

Any idea how this can be done. I have been searching but no luck.
User avatar
uberpolak
Forum Contributor
Posts: 261
Joined: Thu Jan 02, 2003 10:37 am
Location: Next to the bar

Post by uberpolak »

This isn't really a PHP thing, but what you need is a SSI (Server Side Include) to call the script. Insert this line (with the value changed to whatever is correct) into the page where you want it to call the script. Don't put it into your PHP (it's not), just among the normal (X)HTML.

Code: Select all

<!--#exec cgi="/cgi-bin/myscript.cgi"-->
It looks like a comment, but it's not, leave everything alone except for the value after cgi="
oldtimer
Forum Contributor
Posts: 204
Joined: Sun Nov 03, 2002 8:21 pm
Location: Washington State

Post by oldtimer »

But what if i have the cgi on another server. I have a secure server and a non secure server. I want to be able to pass certain information over to it and then back. Right now with just the cgi it works. Just can not figure out how to do it with a php front.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Yeah it's tricky to setup.

Try a Google search for [google]passing php variables another server[/google]
Post Reply