Log in

View Full Version : pass url to php


Mickie D
12-22-2005, 04:30 PM
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
$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



$_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
$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:

$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
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