Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-03-2009, 01:52 AM
pianoman993 pianoman993 is offline
 
Join Date: Oct 2008
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default $_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') . '");');

?>
A form that submits data

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>
A page that receives that data ( the page that will not read the $_GET data )

Code:
<?php
echo $_GET['search'];
?>
So basically if my url was www.mysite.com/index.php?variable=helloworld

and I had a template that included a php page that had this:

Code:
<?php echo $_GET['search']; ?>
I would get nothing instead of helloworld...

Anybody have any ideas?

Any help would be greatly appreciated, thanks!

- pianoman993
Reply With Quote
  #2  
Old 01-03-2009, 02:29 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 01-03-2009, 02:41 AM
pianoman993 pianoman993 is offline
 
Join Date: Oct 2008
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not putting the php code directly in a template file. I am using a plugin to include the php file externally.
Reply With Quote
  #4  
Old 01-03-2009, 02:54 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, my first comment remains.... the only two things you defined in the forum are named "search_value" and "category"
Reply With Quote
  #5  
Old 01-03-2009, 03:01 AM
pianoman993 pianoman993 is offline
 
Join Date: Oct 2008
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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...
Here is the link...

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
Reply With Quote
  #6  
Old 01-03-2009, 03:21 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #7  
Old 01-03-2009, 03:32 AM
pianoman993 pianoman993 is offline
 
Join Date: Oct 2008
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #8  
Old 01-03-2009, 03:38 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It also exists as $myvar in the php page soundsearch.php. Isn't that the script you wanted to use it in?
Reply With Quote
  #9  
Old 01-03-2009, 03:43 AM
pianoman993 pianoman993 is offline
 
Join Date: Oct 2008
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah, I wasn't aware of that! Now we have two methods.
Reply With Quote
  #10  
Old 02-25-2010, 02:51 PM
BlueChipEarth's Avatar
BlueChipEarth BlueChipEarth is offline
 
Join Date: Apr 2009
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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... ><
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:56 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04334 seconds
  • Memory Usage 2,252KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete