Welcome to Geeklog, Anonymous Monday, December 30 2024 @ 12:49 pm EST

Geeklog Forums

staticpages + php + get/post


kyngchaos

Anonymous
I'm trying to get GET/POST to work in staticpages with php. If I set a staticpage to "execute PHP" (second option), my page appears in the GL center block as it should, but no GET or POST vars are available to it. ie:

Text Formatted Code
if (count($_POST)) {
  foreach ($_POST as $k => $v) {
    echo $k . "<br>\n";
  }
}


and page code that submits a POST form, doesn't display any POST vars.

However, if I use the first option "execute PHP (return)", my page displays outside the GL page, before the <HTML> tag (NOT where I want it), yet the POST vars are available to my PHP code.

Is some security thing blocking GET/POST vars from staticpage PHP using the Execute PHP option, but not the Execute PHP (return) option? Or is it something inherent in the output buffering used (I don't know anything about PHP output buffering)? Or something else?
 Quote

Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
Quote by: kyngchaos

I'm trying to get GET/POST to work in staticpages with php. If I set a staticpage to "execute PHP" (second option), my page appears in the GL center block as it should, but no GET or POST vars are available to it.

Is this before or after you submit the form on the page? When the staticpage first loads, there is no form submission. IOW, does the staticpage display your form correctly? Is your form's action the same page as the staticpage?
However, if I use the first option "execute PHP (return)", my page displays outside the GL page, before the <HTML> tag (NOT where I want it), yet the POST vars are available to my PHP code.
That's because you are echoing instead of "return"ing the data. In "Execute PHP (return)" mode, you are supposed return a string containing the page contents:
Text Formatted Code
if (count($_POST)) {
  foreach ($_POST as $k => $v) {
    $display .= $k . "<br>\n";
  }
}
return $display;
If you add an echo statement to your lib-custom.php, it's output will also appear outside the GL page. That is just the nature of using echo with GL.
 Quote

kyngchaos

Anonymous
Is this before or after you submit the form on the page?


After submitting the form. Though even before, I don't see any Geeklog POST (or GET if I change the output to _GET) vars.

That's because you are echoing instead of "return"ing the data.


Oops, that part of the distinction in the docs didn't register ^_^

So, considering that the return method came first, but the second method doesn't give me acces to POST/GET, which is better to use? or more secure, or proper?... Or does it matter - use return so I can GET/POST?
 Quote

All times are EST. The time is now 12:49 pm.

  • 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