vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Reading $_POST in PHP / vB (https://vborg.vbsupport.ru/showthread.php?t=248800)

janaf 08-17-2010 08:56 AM

Reading $_POST in PHP / vB
 
New at php and vB:

I am using PHP direct-eval and using $_POST to read posted data but it seems it is not available with vB? I can not read the passed variable name / value:

PHP Code:

$output $_POST["mystr"]; 

calling the page with
HTML Code:

content.php?305&mystr=hi
Returns nothing

What are my options to pass / read data with vB / php?

I would like to have a simple pull-down menue and read it's value at post / submit, posting to the same page.

Is there another / better way to do this?

I also have a related post problem discribed here:
https://vborg.vbsupport.ru/showthread.php?t=248700

Any input appreciated...

Eric 08-17-2010 09:22 AM

As far as input ($_POST/$_GET/etc), try reading this:

http://www.vbulletin.com/docs/html/codestandards_gpc

So, for example:
PHP Code:

$vbulletin->input->clean_gpc('r''mystr'TYPE_STR); 

And it would be available as:
PHP Code:

$vbulletin->GPC['mystr'

However, this is all going to depend on where in vBulletin you're trying to use this.

janaf 08-17-2010 09:35 AM

Many thanks!

Looks exactly like what I needed to progress.

I am trying to use this in a php direct eval page and php gadget.

janaf 08-18-2010 04:40 PM

Sorry but I am stuck on the first line. Pasted this into a php direct eval page:
PHP Code:

$vbulletin->input->clean_gpc('r''mystr'TYPE_STR); 

I get
HTML Code:

Fatal error: Call to a member function clean_gpc() on a non-object in /var....../phpeval.php(97) : eval()'d code on line 1
and I feel like a fool. What the .... should I do?

blamo 08-25-2011 02:09 AM

Try this:

vB::$vbulletin->input->clean_gpc('r', 'mystr', TYPE_STR);

Marco64Th 08-25-2011 02:37 AM

Are you sure that $vbulletin is in scope?

Try adding a:
PHP Code:

global $vbulletin

Just before the call to clean_gpc().

nhawk 08-25-2011 02:08 PM

You also need to understand the difference between GET, POST and REQUEST. In general...

GET = Anything passed via a URL
POST = Anything passed via an input (<input type=...etc>)
REQUEST = All GET, POST and COOKIE data.

Using these with vB and not cleaning them with $vbulletin->input->clean.. is bad practice as this could possibly introduce rogue code into the system.

This code..
Code:

$vbulletin->input->clean_gpc('r', 'mystr', TYPE_STR);
Could be passing more information than you need.

It's best to narrow down what you need with
Code:

$vbulletin->input->clean_gpc('p', 'mystr', TYPE_STR);
or
Code:

$vbulletin->input->clean_gpc('g', 'mystr', TYPE_STR);
If I'm wrong on that, someone please correct me.

kh99 08-25-2011 02:24 PM

I'm not an expert on the matter, but I agree with what nhawk says above, except that I think I'd make the decision on using GET, POST, or REQUEST based on if I thought the script was useful as something that would be used as a link or url. That is, even if you're using it to process form data, if you could see it being useful for someone to enter the paramters in a url or to create a link to it, then you could use REQUEST instead of POST.

Also, I think it's important to note that calling clean_gpc() with TYPE_STR does almost nothing to the value, so you still need to be careful if you're using it in a database query or including it directly in the output.


All times are GMT. The time now is 09:54 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00995 seconds
  • Memory Usage 1,735KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (2)bbcode_html_printable
  • (5)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete