Treating CGI output as PHP?
Posted: Wed Jun 16, 2010 6:35 am
Longstanding programmer here, but very new to web development...I'm not sure whether I'm asking this is the right section, as most of my confusion is because I'm not sure where to look for an answer...
What I have is an old, old program which we want to convert to a web application without having to rewrite all the computation. So, executable is compiled and renamed to .cgi, and I also have a menu + forms in php format. User clicks on the menu item, sees the correct form, fills it in, values are passed to the CGI executable, calculations are done, CGI executable writes to standard output and this comes up in the browser. All this works fine.
My problem is that the CGI output goes straight to the browser as-is. I'd like it to be treated as php, so I can, for instance, include my menu at the top with <?php include("index.php"); ?> so the user can go on and do something else. What I can't figure out is how to do that. Everything I've found is geared towards changing how different filetypes are processed...but I don't have a filename with an extension, just the CGI output.
If I save the output from my CGI program as a file with a .php extension and reload it into the browser, I get my menu as expected, so it isn't an error in the output.
Apache 2.2.15 (Win32) PHP/5.3.2, if it matters.
This has to be easy, or at least possible, right?
Many thanks for any assistance.
What I have is an old, old program which we want to convert to a web application without having to rewrite all the computation. So, executable is compiled and renamed to .cgi, and I also have a menu + forms in php format. User clicks on the menu item, sees the correct form, fills it in, values are passed to the CGI executable, calculations are done, CGI executable writes to standard output and this comes up in the browser. All this works fine.
My problem is that the CGI output goes straight to the browser as-is. I'd like it to be treated as php, so I can, for instance, include my menu at the top with <?php include("index.php"); ?> so the user can go on and do something else. What I can't figure out is how to do that. Everything I've found is geared towards changing how different filetypes are processed...but I don't have a filename with an extension, just the CGI output.
If I save the output from my CGI program as a file with a .php extension and reload it into the browser, I get my menu as expected, so it isn't an error in the output.
Apache 2.2.15 (Win32) PHP/5.3.2, if it matters.
This has to be easy, or at least possible, right?
Many thanks for any assistance.