EllisLab text mark
Advanced Search
     
Is it possible to retrieve $_POST array values on search results_page?
Posted: 25 June 2008 10:00 AM   [ Ignore ]
Avatar
Joined: 2007-02-02
982 posts

Hi,

I have tried to retrieve $_POST array values on search results_page and found that neither usual

<?php 
$myvar 
$_POST["some_name"];
echo 
$myvar
?> 

nor ExpressionEngine’s

<?php
global $IN;
$myvar =  $IN->GBL('some_name''POST'
echo 
$myvar
?> 

does work.

The code

<?php
echo count($_POST);
?> 

outputs zero on search results_page.

In contrast to $IN->GBL(‘some_name’, ‘POST’), $IN->GBL(‘some_name’, ‘COOKIE’) works correctly on search results_page.

So, my question: what’s happening with $_POST array on search results_page? Is it possible to to retrieve $_POST array values on search results_page? Or maybe ExpressionEngine somehow manipulates with those values thus making them unavailable?

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

 
Posted: 25 June 2008 10:14 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2002-05-20
12626 posts

I suspect the post array may be stripped when the search form is submitted- if you’re passing extra values along w/the form.  Is that the case?

 Signature 
 
Posted: 25 June 2008 10:15 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2002-05-20
12626 posts

And thinking on what you’re going for- any way you can make use of the tracker array to figure out where they’re coming in from?

 Signature 
 
Posted: 25 June 2008 11:58 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2007-02-02
982 posts

Hi Robin,

I tried to retrieve $_POST array variables both passing extra values with the form and without passing extra values with the form - and result is the same. Does it means that after submitting a form all values of $_POST array get deleted?

Thanks for pointing out at tracker array - it is really useful construct although not exactly what I need.

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

 
Posted: 25 June 2008 12:04 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2002-05-20
12626 posts

Hm- think it’s the redirect at the end- you’d lose the post array then- see the do_search function in mod.search.php.

 Signature 
 
Posted: 26 June 2008 08:36 AM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2007-02-02
982 posts

Hi Robin,

Many thanks for explanation. Now it’s clear what’s happening with $_POST array on search results_page.

The situation with search results_page is quite unfortunate: if there is a need to pass some data to it neither url_segments can be used (forum thread), nor $_POST array variables. As it turns out the only means available for passing data to search results_page are cookies.

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

 
Posted: 26 June 2008 11:30 AM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2002-05-20
12626 posts

Yep- only way I see to do it.  If it’s mission critical, could hack it.  Which wouldn’t, I think, be too hard.  Might just try tweaking that redirect to stick an extra segment in and see if it works.  If so- that’s the route I’d go if it’s mission critical.  And put in an FR so it takes extra segments.  I didn’t poke the code hard enough to see why it doesn’t seem to like them.

But- we good to close out?  Or you want to shift to ‘How to’ to brainstorm on it more?

 Signature 
 
Posted: 26 June 2008 12:17 PM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2007-02-02
982 posts

Hi Robin,

It’s mission critical, but I do not feel myself as yet strong enough in PHP to hack ExpressionEngine’s core files. I will go cookies root since this is well known to me - I have even published Cookie Plus plugin.

There is no need to shift this stuff into “How to” forum. The thread can be closed.

 Signature 

Full list of add-ons here

Child Categories
Browser Sniff
Category Id
Entries Number

 
Posted: 26 June 2008 12:39 PM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Avatar
Joined: 2002-05-20
12626 posts

wink  Hacks are a pain- so if the cookie will do, it’s the better call.  And a feature request is still a good idea as well.

I’ll go ahead and close this puppy out.

 Signature