Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   PHP (http://www.programmingforums.org/forum29.html)
-   -   How to pass variables like a URL? (http://www.programmingforums.org/showthread.php?t=10862)

ZeeMan Jul 27th, 2006 6:14 PM

How to pass variables like a URL?
 
I would like to learn how to pass variables with URLs like:
http://mysite.com/directory/script.php/variable
I've seen it done before in PHP, ASP and possibly Perl. I know that it is possible, I just don't know how to do it or what the proper name is.

niteice Jul 27th, 2006 7:00 PM

Maybe I'm misunderstanding what you're saying, but the web server rewrites it into something like:

http://mysite.com/directory/script.php?var1=variable

You can then access it with the $_GET array. i.e. $_GET["var1"]

Sane Jul 27th, 2006 7:07 PM

:

  1. echo $_SERVER['REQUEST_URI'];


That will output "/script.php/variable", which could easily be parsed in to what you need. Check the docs for what else $_SERVER holds, that could be of relevance.

Xeoncross Aug 10th, 2006 2:24 PM

Understanding PHP's GET and POST
 
I wrote a lesson on understanding PHP's $_GET and $_POST functions. I really recommend that you read it if you want to use these functions. You can read it at:
http://www.learnphpfree.com/lesson-5...post-vt27.html

oh, and let me know what you think :)

DaWei Aug 10th, 2006 3:36 PM

Nice article. As a quibbler, I would suggest that (if you are going to disseminate something widely, and don't have an editor) you proofread many times.
Quote:

Now that wasn't to hard was it? ...was it???
That's a nasty one to catch. No spell checker is going to pick up on that 'to' and suggest 'too.' Most grammar checkers will conclude that something is wrong, but may suggest that it has something to do with misuse of infinitives. Dealing with this kind of typo is such a pain in the butt that I also recommend you get the economy-sized bottle of aspirin.

Sane Aug 10th, 2006 6:33 PM

Xeoncross, to be frank, what does that have to do with the original poster's question? It's relevant to $_GET, $_POST, but not about them. This sounds like you're just grabbing an opportunity to advertise your website.

jaeusm Aug 11th, 2006 12:02 AM

Seems relevant to me...

Sane Aug 11th, 2006 2:08 AM

Well, I did say it was relevant. But it still has nothing to do with his question. $_POST and $_GET variables don't contain the raw data passed in http://mysite.com/directory/script.php/variable. See my first post for more information.

But enough of this, I'm off. =\

AntiNinja Aug 11th, 2006 2:16 AM

Quote:

I'm off
too see the wizard

sry just had too... :)

big_k105 Aug 11th, 2006 2:42 AM

I can't see any other way to do this other then the way that sane mentioned. Nothing about GET or POST will do this if you are trying to get your variable via file.php/var the onlyway I see to get variables from the url is to do $_GET['var'] or $_REQUEST['var'] from the url file.php?var=something


All times are GMT -5. The time now is 12:23 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC