drpeppper
12-11-2010, 10:39 AM
I have set up a dynamic PHP page that includes a custom form like this from which I want to use the input field's value for a database query search:
$search_output .= '<form name="medal_search" action="' . $searchURL . '" method="post">';
$search_output .= '<label for="medal_search_player">Spieler suchen (Name oder SteamID eingeben):</label>';
$search_output .= '<input name="medal_search_player" type="text" value="' . $playerSearchString . '" />';
$search_output .= '<input id="medal_search_token" name="securitytoken" value="' . vb::$vbulletin->userinfo[securitytoken] . '" type="hidden" />';
$search_output .= '<input name="do" value="process" type="hidden" />';
$search_output .= '<input type="submit" value="Suchen..." />';
$search_output .= '</form>';
I pretty soon realised that $_POST and $_GET are not working so I tried using this which works but always gives me an empty variable inside the dynamic PHP:
vB::$vbulletin->input->clean_gpc('p', 'medal_search_player', TYPE_STR);
When I move this line of code into a new plugin it works though. So here's the code from the plugin I created:
$medalStatsSearchVars = array(
'medal_search_player' => vB::$vbulletin->input->clean_gpc('p', 'medal_search_player', TYPE_STR),
'name' => vB::$vbulletin->input->clean_gpc('g', 'name', TYPE_STR),
'steamid' => vB::$vbulletin->input->clean_gpc('g', 'steamid', TYPE_STR)
);
vB_Template::preRegister('vbcms_content_phpeval_pa ge', array('medalStatsSearchVars' => $medalStatsSearchVars));
echo $medalStatsSearchVars['medal_search_player'] . '|' . $medalStatsSearchVars['name'];
... the echo is just for testing and it correctly displays the value but it's still not working inside the dynamic PHP page no matter how I try to access it. Note that I preregistered the variable for the template that is used by dynamic PHP content. I've tried to use it with the following hooks: vbcms_phpeval_populate_start, global_start, init_startup (this last one crashes the whole system) but I just can't get it to display the variable inside the dynamic PHP content. I've tried this but the vars are always empty:
$medalStatsSearchVars['medal_search_player']
$vbulletin->GPC['medal_search_player']
This is really frustrating and I hope someone can point me into the right direction with this problem here.
$search_output .= '<form name="medal_search" action="' . $searchURL . '" method="post">';
$search_output .= '<label for="medal_search_player">Spieler suchen (Name oder SteamID eingeben):</label>';
$search_output .= '<input name="medal_search_player" type="text" value="' . $playerSearchString . '" />';
$search_output .= '<input id="medal_search_token" name="securitytoken" value="' . vb::$vbulletin->userinfo[securitytoken] . '" type="hidden" />';
$search_output .= '<input name="do" value="process" type="hidden" />';
$search_output .= '<input type="submit" value="Suchen..." />';
$search_output .= '</form>';
I pretty soon realised that $_POST and $_GET are not working so I tried using this which works but always gives me an empty variable inside the dynamic PHP:
vB::$vbulletin->input->clean_gpc('p', 'medal_search_player', TYPE_STR);
When I move this line of code into a new plugin it works though. So here's the code from the plugin I created:
$medalStatsSearchVars = array(
'medal_search_player' => vB::$vbulletin->input->clean_gpc('p', 'medal_search_player', TYPE_STR),
'name' => vB::$vbulletin->input->clean_gpc('g', 'name', TYPE_STR),
'steamid' => vB::$vbulletin->input->clean_gpc('g', 'steamid', TYPE_STR)
);
vB_Template::preRegister('vbcms_content_phpeval_pa ge', array('medalStatsSearchVars' => $medalStatsSearchVars));
echo $medalStatsSearchVars['medal_search_player'] . '|' . $medalStatsSearchVars['name'];
... the echo is just for testing and it correctly displays the value but it's still not working inside the dynamic PHP page no matter how I try to access it. Note that I preregistered the variable for the template that is used by dynamic PHP content. I've tried to use it with the following hooks: vbcms_phpeval_populate_start, global_start, init_startup (this last one crashes the whole system) but I just can't get it to display the variable inside the dynamic PHP content. I've tried this but the vars are always empty:
$medalStatsSearchVars['medal_search_player']
$vbulletin->GPC['medal_search_player']
This is really frustrating and I hope someone can point me into the right direction with this problem here.