The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
$_GET and $_POST variables are not recognized?!
Hello there Vbulletin experts I have a bit of a problem. I have a page that has $_GET variables in the URL. The problem is that Vbulletin is not recognizing that there are variables there so for instance if my script says print $_GET['variable'] I get nothing. Here's what I got.
I have a custom template named SOUND_SEARCH Code:
<?php // ####################### SET PHP ENVIRONMENT ########################### error_reporting(E_ALL & ~E_NOTICE); // #################### DEFINE IMPORTANT CONSTANTS ####################### define('NO_REGISTER_GLOBALS', 1); define('THIS_SCRIPT', 'SOUND_SEARCH'); // change this depending on your filename // ################### PRE-CACHE TEMPLATES AND DATA ###################### // get special phrase groups $phrasegroups = array( ); // get special data templates from the datastore $specialtemplates = array( ); // pre-cache templates used by all actions $globaltemplates = array( 'TEST', ); // pre-cache templates used by specific actions $actiontemplates = array( ); // ######################### REQUIRE BACK-END ############################ require_once('./global.php'); // ####################################################################### // ######################## START MAIN SCRIPT ############################ // ####################################################################### $navbits = array(); $navbits[$parent] = 'Sound Search'; $navbits = construct_navbits($navbits); eval('$navbar = "' . fetch_template('navbar') . '";'); eval('print_output("' . fetch_template('SOUND_SEARCH') . '");'); ?> Code:
<div style="border:1px solid #333;padding:15px;"> <form name="search" method="get" action="soundsearch.php"> <input type="text" style="width:110px;" name="search_value" /> in <Select name="category"> <Option value="songs">Songs</option> <Option value="artists">Artists</option> </Select> <input type="submit" name="search" value="search" /> </form> </div> Code:
<?php echo $_GET['search']; ?> and I had a template that included a php page that had this: Code:
<?php echo $_GET['search']; ?> Anybody have any ideas? Any help would be greatly appreciated, thanks! - pianoman993 |
#2
|
||||
|
||||
You don't have a variable named "search" in your form. You should probably go read up on forms and php. Also, you can't put php in a template like your line of code above.
|
#3
|
|||
|
|||
I'm not putting the php code directly in a template file. I am using a plugin to include the php file externally.
|
#4
|
||||
|
||||
Well, my first comment remains.... the only two things you defined in the forum are named "search_value" and "category"
|
#5
|
|||
|
|||
Alrighty, so here are the two pages I'm having trouble with.
Here is the original PHP page that has this code: Code:
<?php echo $_GET['category']; ?> Sorry, the search page is currently under construction... As you can see, everything is working as it is supposed to be. --------- This page has a simulated form request as you can tell by the present $_GET variables in the URL. But this time to information was grabbed from the URL. Do you know why this might be? I took you up on your variable suggestion by changing the variable to category. - Pianoman993 |
#6
|
||||
|
||||
Try putting something like:
$myvar = $_GET['category']; in soundsearch.php prior to evaling the template. Then, in the template, put $myvar somewhere. Does that work? |
#7
|
|||
|
|||
Ahhh! I believe we have an answer. I prepped the plugin variable with a $_GET['category'] variable. Vbulletin was now aware of that and parsed the value. Woot!
Thank you for all your help :-D |
#8
|
||||
|
||||
It also exists as $myvar in the php page soundsearch.php. Isn't that the script you wanted to use it in?
|
#9
|
|||
|
|||
Ah, I wasn't aware of that! Now we have two methods.
|
#10
|
||||
|
||||
I've got a similar problem:
http://www.lawnsite.com http://www.lawnsite.com/forumdisplay.php?f=123 That's one BB with an internal style set to one of the forums, so you get a "Lawnsite" style and "LHDB Site" style. I've set up the search in the LHDB style to search only within that forum (and child forums). The problem is, when you search, it sets the style back to Lawnsite's style, but only shows results from LHDB Site (forum). What I wanted to do was set another $_POST variable (forumstyle) that would be picked up in the "style_fetch" hook, and set the style to LHDB site (so that people don't get confused, and so when they search again they'll again be searching LHDB... basically making them seem like two separate websites). I then tried to use a cookie, but it seems to work intermittently... I'd much rather go with the $_POST method, but I can't seem to get the variable back in the style_fetch hook... Is there some way I can get ahold of this variable without actually editing the search.php file? --------------- Added [DATE]1267122981[/DATE] at [TIME]1267122981[/TIME] --------------- Well, I went with a cookie that expires in 5 seconds... if anyone has a suggestion that's better than this, please let me know!!! I'm still curious as to how we can get ahold of $_POST data through hooks after a search... and still use this information to change the style with style_fetch. vBulletin is such a massive beast... >< |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|