1
suyog
Get get and post variables in custom block?
  • 2004/12/3 17:50

  • suyog

  • Just popping in

  • Posts: 9

  • Since: 2004/9/6 1


Hey all,

I am trying to write a custom block for the myReviews module.

This is what I want to do:

My query string is:
http://www.dogmatrix.com/modules/myReviews/detailfile.php?lid=102

I want to get the "lid" value (Which is 102 here) in a custom block.

For the custom block I did this:
function b_myReviews_author_show() {

global $xoopsDB, $xoopsUser, $xoopsModuleConfig;
$myts = &MyTextSanitizer::getInstance();
// $lids = intval($HTTP_GET_VARS['lid']);
$lids=( $HTTP_GET_VARS['lid'] && $HTTP_GET_VARS['lid'] > 0 ) ? $HTTP_GET_VARS['lid'] : 0;
$block = array();

if ($lids > 0)
{
do something
}
else ( $lids == 0)
{
do something
}


However my $lids value always comes up as Zero no matter which page I am looking at, even with the above query string. Is there something wrong i am doing here? do I get the value of "lid" in the block.

Please help! thanks a million!

Suyog

2
hervet
Re: Get get and post variables in custom block?
  • 2004/12/3 18:46

  • hervet

  • Friend of XOOPS

  • Posts: 2267

  • Since: 2003/11/4


Hi,

How do you call your function ?
May you should include the valude of your lid as a parameter of the function ?

Bye,
Hervé

3
ackbarr
Re: Get get and post variables in custom block?

the long request vars ($HTTP_POST_VARS, $HTTP_GET_VARS, etc) are not automatically globalized inside a function (or in an eval'd piece of code, like a custom block).

You have two options:

1. globalize $HTTP_POST_VARS and $HTTP_GET_VARS:
global $HTTP_POST_VARS$HTTP_GET_VARS;


2. use the $_POST, $_GET arrays instead, which are 'auto-global' (preferred)

the second option is preferred because the default settings for PHP 5 disable the long request vars.

4
suyog
Re: Get get and post variables in custom block?
  • 2004/12/3 19:05

  • suyog

  • Just popping in

  • Posts: 9

  • Since: 2004/9/6 1


Quote:


2. use the $_POST, $_GET arrays instead, which are 'auto-global' (preferred)

the second option is preferred because the default settings for PHP 5 disable the long request vars.


Thanks a million!!!!! This solution worked. I had tried this before, but I was making a mistake of converting it to intval before instead of taking it as it is - didnt know it made a diff (should it?), but hell, this works!!!

Thanks again!

Suyog

Login

Who's Online

276 user(s) are online (225 user(s) are browsing Support Forums)


Members: 0


Guests: 276


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits