Welcome to Geeklog, Anonymous Wednesday, November 27 2024 @ 10:37 am EST
Geeklog Forums
Accessing site variables from a "php static page" ;)
Status: offline
JoelF
Forum User
Chatty
Registered: 07/18/04
Posts: 39
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
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
14
8
Quote
kyle
Anonymous
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>"
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>"
11
11
Quote
Kyle
Anonymous
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>"
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>"
13
12
Quote
Status: offline
Dirk
Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
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
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
11
13
Quote
Kyle
Anonymous
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>"
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
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
7
7
Quote
mach
Anonymous
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?
also, you mention what is not displaying, but can you tell us what is displaying?
11
11
Quote
Kyle
Anonymous
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.
remote address=
username=
http remote address
site url=
I'm using geeklog 1.3.9sr2 if that helps.
7
10
Quote
Kyle
Anonymous
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>"
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>"
12
12
Quote
All times are EST. The time is now 10:37 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content