![]() |
passing variables through a url
hello,
i have a url like this: index.php?category=something when i try to echo out $category on my local computer it doesnt work but when i try it on a hosting server it works why wont it work locally? i put register_globals to on. anyone know? |
What's your code? Are you using short PHP tags?
|
Quote:
ok here is my code this is the left navigation categories so when one of them is clicked the page will redirect to it. Code:
<?phpCode:
<?php |
Shouldn't you declare $catagory before using it?
PHP Code:
|
Steer well clear of register_globals, they are downright daft as well as posing a considerable security issue if not done correctly.
Use the super globals: PHP Code:
|
Best way to pass it it definitly through GET's, unless you're posting (huge) amounts of data. Then, of course, you can use POST or rather use a database.
For later use, you can also save it encoded into a Cookie, and remove it when you're done. (first setcookie with the data, and then the same but with empty values) |
my page doesnt have a form on it , im grabbing the variables directly from the url
so if the url was index.php?category=cell phones if i did the following on the server it would work but not on my pc echo $category , the output would show cell phones if im not using a form method such as post or get how would post or get even work? |
Data that is passed through a URL is considered form data.
Just try this: PHP Code:
Code:
Yeah Toast |
An even better way, to make sure that it all comes through, is base64 encoding.
There are so much ways to do this. I mostly do this trough encoding the string that I want to send, and then decoding it on the other send. ?this=a2lua3ksIGp1c3QgdHJ5aW5nIHRvIHNlZSBpZiB5b3UgYXJlIG dvaW5nIHRvIGRlY29kZSB0aGlzLg== Base64 Encoder and Decoder What you can do, if you want to send entire arrays, first serialise() the array, and then encode it as base64. When you want to retrieve it, decode it and then unserialise() it. |
Quote:
|
| All times are GMT. The time now is 05:50 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0