vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   pass url to php (https://vborg.vbsupport.ru/showthread.php?t=103534)

Mickie D 12-22-2005 04:30 PM

pass url to php
 
i need to pass a url to a php page and i need the php tag to take the code in the url and perform an action on the page

ok let me explain a little better

if a member clicks this link below

http://www.mysite.com/forum/store.php?item=ipod

i want to be able to send that url to the store.php and where it says ipod i want the php page to display ipod listings from my store

i am not bothered about displaying the stuff as i can work that but i need to know how to make urls be able to make the php page work (i know it already works because the search engine on that page can display all this from my store page)

i know some php but i would really appreicate some help with this

Regards
Mickie D

Guest190829 12-22-2005 06:19 PM

PHP Code:

$vbulletin->input->clean_gpc('r''item'TYPE_NOHTML); 

if (
$vbulletin->GPC['item'] == 'whatever')
{
  
// do something


The above code will take item from the url, and if it equals the text 'whatever' it will //do something.

Mickie D 12-22-2005 06:45 PM

yeah cheers danny i was reading through the php manual and found the

PHP Code:


$_REQUEST 

code and it has been good can you recommend using your version over the request i was reading that in vbulletin alot of the post and get globals are replaced with the code you said

and one last thing can you tell me what the clean_gpc code at the top does

thanks very much for the reply im very greatful because i dont know alot of the vbulletin built in codes as much as i am confident with the php stuff

and one last thing aswell can you tell me would it be easier to make a switch if i have alot of codes instead of using lots of if's and can you tell me the best way to do it in vbulletin

Regards
Mickie D

Guest190829 12-22-2005 06:53 PM

PHP Code:

 $vbulletin->input->clean_gpc() 

The above function sanitizing any variables that you are passing via GET, POST, or REQUEST. It's very important that you do this to avoid certain injections in your code.

About the $vbulletin->GPC thing, your code must follow this standard or else the code will not work. The sanitized variable resulting from the $vbulletin->input->clean_gpc() is assigned to it. However in the case of checking if the request == something, you can still use $_REQUEST['whatever'], but I would reccomend following vbulletin's coding standards and using $vbulletin->GPC[].

Mickie D 12-22-2005 06:57 PM

one last last thing and i will be so happy lol

i have been trying to take a profile field (which i made [field5]) but when i try and make the url in the postbit template

http://www.mysite.com/forums/store.php?item=$post['field5']

i get an error in the templates about a parse error and also is that the right conditional to get the profile field entered into a url so it can add to the rest of my code ?

thanks again for the help

Guest190829 12-22-2005 07:10 PM

Hm, I'm not really sure if the below will work but try:

PHP Code:

$userinfo[field5

It might only be in member.php in which that variable works...

Mickie D 12-22-2005 07:21 PM

managed to get it working with the $post[field5] but me being silly and jumping the gun found out that it posts the url as it should but the script does not recognise the actual $post[field5] because its not been added by myself in the if statement :(

i could never add them all to the php file it would be silly and we have alot of signups all with different stores (hence what the $item is for)

is it possible to make the script turn anything that is entered in a url be searched for as $item instead of having to know from the script what it is ?

i.e

http://www.mysite.com/forums/store.php?item=anything

and then it will search a product (because i can search using a form from my search page aimed at its self (store.php) and it will look for anything because in the form the variable is $item)


but thanks very much danny you have been a great help and made me code nice and tidy

Regards
Mickie D

Guest190829 12-22-2005 07:25 PM

Well you would do some sort of mysql query using a where clause and the 'anything' being what it's looking for.

Mickie D 12-22-2005 07:30 PM

Quote:

Originally Posted by Danny.VBT
Well you would do some sort of mysql query using a where clause and the 'anything' being what it's looking for.

i get ya ;)

you mean like because the profile field is stored in the database i can do a call to the database looking for the profile[field5] and then returning that as the $item

ill get looking into this im not great with mysql but i know where to start and you have helped me greatly.

top man danny can see why you are a mod here !

Regards
Mickie D


All times are GMT. The time now is 02:12 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.01072 seconds
  • Memory Usage 1,737KB
  • 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
  • (4)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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