Posted on: 07/25/04 02:09pm
By: JoelF
The name 'php static page' is starting to crack me up (just an aside - sorry)... In any case, I'm working on a membership enrollment page for a club that will be using GL for its site. I've got the first page with 'fill in the blanks form', and the called page (a php-enabled static page) that now presents the form information, while mailing the enrollment info to a predefined mail address. That's all good.
Now I'm trying to write to a log file during the process and finding it hard to access any site variables, like 'site_url', 'path' or 'path_html'. I must still be missing something about the environment that these php static pages run in...
I tried adding
global $_CONF;
to the top of the php static page, and then later on referring to a variable like this:
$_CONF('site_url')
as I would have in lib-custom.php, but anything like this causes the page to not load.
Am I taking the completely wrong approach on getting to these values?
Thanks in advance,
Joel
Accessing site variables from a "php static page" ;)
Posted on: 07/25/04 02:18pm
By: Dirk
[QUOTE BY= JoelF] $_CONF('site_url')[/QUOTE]
This is PHP, not BASIC
Try square brackets: $_CONF['site_url']
bye, Dirk
Accessing site variables from a "php static page" ;)
Posted on: 07/25/04 02:46pm
By: JoelF
[QUOTE BY= Dirk] [QUOTE BY= JoelF] $_CONF('site_url')[/QUOTE]
This is PHP, not BASIC Try square brackets: $_CONF['site_url']
bye, Dirk[/QUOTE]
And not C++ or C# or ... Oops. At least I wasn't 100 miles off course.
Thanks,
Joel
Accessing site variables from a "php static page" ;)
Posted on: 12/20/04 01:37pm
By: Anonymous (kyle)
I'm trying to access vars and I'm getting strange results. When I view the page from the static pages admin link everything works great. When I view the static page as a centerblock and position top of page, and execute php in block none of the vars show. What do I need to do for this to work?
print("I see you as $_USER['username']<br>"
;
print("I see you as $_CONF['REMOTE_ADDR']<br>"
;
print("-----------------<br>"
;
print("$PHP_SELF <br>"
;
print("$DOCUMENT_URI <br>"
;
print("$QUERY_STRING <br>"
;
print("$REQUEST_URI <br>"
;
print("$REMOTE_ADDR <br>"
;
print("$HTTP_REFERER <br>"
;
Accessing site variables from a "php static page" ;)
Posted on: 12/20/04 01:57pm
By: Dirk
Declare the variables as global
.
bye, Dirk
Accessing site variables from a "php static page" ;)
Posted on: 12/20/04 02:25pm
By: Anonymous (Kyle)
This still isn't working for me. How should I be dclaring global?
global $_CONF,$USER;
print("I see you as {$_CONF['REMOTE_ADDR']}<br>"
;
print("I see you as $_USER['username']<br>"
;
print("site url= $_CONF['site_url'] <br>"
;
print("$PHP_SELF <br>"
;
print("$DOCUMENT_URI <br>"
;
print("$HTTP_REFERER <br>"
;
print("$AUTH_TYPE <br>"
;
Accessing site variables from a "php static page" ;)
Posted on: 12/20/04 02:46pm
By: Dirk
Typo? It's $_USER (with an underscore)
Also, $_CONF['REMOTE_ADDR'] doesn't exist. You're probably looking for $HTTP_SERVER_VARS['REMOTE_ADDR'] or $_SERVER['REMOTE_ADDR']. Use the latter, if possible, because $_SERVER is a superglobal and doesn't have to be declared global.
bye, Dirk
Accessing site variables from a "php static page" ;)
Posted on: 12/20/04 05:02pm
By: Anonymous (Kyle)
I fixed the typo but I'm still just not getting it. I'm trying the following code and I don't see any values for any of the vars??
global $_CONF, $_USER;
print("remote address= $_SERVER['REMOTE_ADDR'] <br>"
;
print("username= $_USER['username']<br>"
;
print("http remote address $HTTP_SERVER_VARS['REMOTE_ADDR'] <br>"
;
print("site url= $_CONF['site_url'] <br>"
;
[QUOTE BY= Dirk] Typo? It's $_USER (with an underscore)
Also, $_CONF['REMOTE_ADDR'] doesn't exist. You're probably looking for $HTTP_SERVER_VARS['REMOTE_ADDR'] or $_SERVER['REMOTE_ADDR']. Use the latter, if possible, because $_SERVER is a superglobal and doesn't have to be declared global.
bye, Dirk[/QUOTE]
Accessing site variables from a "php static page" ;)
Posted on: 12/20/04 05:25pm
By: Anonymous (mach)
try putting that into a function and set your page to 'return' rather than execute. see if that makes any diff. don't forget to keep that global statement in there.
also, you mention what is not displaying, but can you tell us what is displaying?
Accessing site variables from a "php static page" ;)
Posted on: 12/20/04 05:31pm
By: Anonymous (Kyle)
Here is what displays using the code posted above:
remote address=
username=
http remote address
site url=
I'm using geeklog 1.3.9sr2 if that helps.
Accessing site variables from a "php static page" ;)
Posted on: 12/20/04 10:38pm
By: Anonymous (Kyle)
Looks like I forgot the braces
For anyone else who may run into the same problems I did here is my solution:
global $_CONF, $_USER;
print ("username={$_USER['username']} <br>"
;
print("remote address= {$_SERVER['REMOTE_ADDR']} <br>"
;
print("http remote address {$HTTP_SERVER_VARS['REMOTE_ADDR']} <br>"
;
print("site url= {$_CONF['site_url']} <br>"
;
Accessing site variables from a "php static page" ;)
Posted on: 03/01/05 10:42am
By: Ktulu
Thanx! Really helped A LOT!!!!