Gossamer Forum
Home : Products : Gossamer Links : Discussions :

How do I extract a php variable in one directory into a cgi file in another directory?

Quote Reply
How do I extract a php variable in one directory into a cgi file in another directory?
Ok since I really want an answer to my ultimate problem (http://www.gossamer-threads.com/...?post=305909;#305909), I came up with a universal new post to use in other various code resource sharing forums on the web (if anyone has a good "Post your questions, and an expert will try to provide answers!" type of website that I can post the following question, please let me know). I've tried to simplify as much as possible exactly what needs to be done, so here it is for anyone who is really good in both cgi & php:


I need someone to come up with a piece of code that basically extracts a variable in a php file from one directory into a cgi file in another directory. For example:

Let's say the variable needed is in http://www.mysite.com/...rectory/variable.php, and the code looks like:

<?
$variable = "It works!";
?>

The variable needs to be extracted to: http://www.mysite.com/...irectory/extract.cgi
The variable also needed to be extracted to: http://www.mysite.com/...irectory/extract.php, but I got this part working myself, as I'm fairly good with php.

So to elaborate, the issue I'm having is that the extract.cgi file uses a template called cgitemplate.html & the extract.php file uses a template called phptemplate.html, and so extracts the variable into two different directories:

http://www.mysite.com/...irectory/extract.cgi -> I don't know how to make this part work
http://www.mysite.com/...irectory/extract.php -> This part works, as follows:

In the phptemplate.html file, all I had to do was add the following pieces of code to make everything work:

<?
chdir("../");
chdir("./variabledirectory");
require("variable.php");
echo $variable;
?>

So I guess I'm trying to figure out how to re-write the above php code that's in the phptemplate.html file into cgi code that will be in the cgitemplate.html file? How do I translate this from php into cgi correctly? Thank you in advance.
Subject Author Views Date
Thread How do I extract a php variable in one directory into a cgi file in another directory? V.E.C.T.O.R. 7483 May 25, 2009, 12:16 PM
Thread Re: [V.E.C.T.O.R.] How do I extract a php variable in one directory into a cgi file in another directory?
Andy 7224 May 26, 2009, 12:28 AM
Post Re: [Andy] How do I extract a php variable in one directory into a cgi file in another directory?
V.E.C.T.O.R. 7223 May 26, 2009, 9:22 PM
Thread Re: [V.E.C.T.O.R.] How do I extract a php variable in one directory into a cgi file in another directory?
V.E.C.T.O.R. 7209 Jun 2, 2009, 12:04 PM
Thread Re: [V.E.C.T.O.R.] How do I extract a php variable in one directory into a cgi file in another directory?
V.E.C.T.O.R. 7207 Jun 2, 2009, 10:24 PM
Thread Re: [V.E.C.T.O.R.] How do I extract a php variable in one directory into a cgi file in another directory?
Andy 7183 Jun 2, 2009, 11:16 PM
Thread Re: [Andy] How do I extract a php variable in one directory into a cgi file in another directory?
V.E.C.T.O.R. 7229 Jun 3, 2009, 6:15 AM
Thread Re: [V.E.C.T.O.R.] How do I extract a php variable in one directory into a cgi file in another directory?
Andy 7191 Jun 3, 2009, 6:25 AM
Thread Re: [Andy] How do I extract a php variable in one directory into a cgi file in another directory?
V.E.C.T.O.R. 7191 Jun 4, 2009, 10:34 PM
Post Re: [V.E.C.T.O.R.] How do I extract a php variable in one directory into a cgi file in another directory?
V.E.C.T.O.R. 7184 Jun 5, 2009, 6:46 AM