Jump to content

Archived

This topic is now archived and is closed to further replies.

RagingEagle

Taking information out of URL

Recommended Posts

For my website I need to take the following URL:

http://www.mysite.com/index.php&db_id=2&filename=3.zip

And get the information from filename so that I can display the text "3.zip" on my webpage. I know I can do that with Get however Get only works when it calls the information from the URL bar. The above URL is not going to be in the URL bar but rather actual code on the webpage. Is it possible to do what I want?

Thanks,
RE

Share this post


Link to post
Share on other sites
Take a look at the functions [url=http://us2.php.net/parse_url]parse_url()[/url] and [url=http://us2.php.net/parse_str]parse_str()[/url]. They should do what you want.

Ken

Share this post


Link to post
Share on other sites
Also, you could just use the $_REQUEST variable and do something like this:

[code]
$file = $_REQUEST['filename'];

include($file);
[/code]

as long as the file you're working with is in the same directory as the referer.

Share this post


Link to post
Share on other sites
No, the OP already said he couldn't use the $_GET array since the string in question is not coming from the URL but from a file. The $_REQUEST array is just a combination of the $_GET and $_POST arrays and would be of no use to the OP.

Ken

Share this post


Link to post
Share on other sites
[quote author=kenrbnsn link=topic=110657.msg447767#msg447767 date=1160109888]
Take a look at the functions [url=http://us2.php.net/parse_url]parse_url()[/url] and [url=http://us2.php.net/parse_str]parse_str()[/url]. They should do what you want.
[/quote]

I tried using parse_url() before I came here and it didn't work. But I didn't know about parse_str() which worked :). Thanks for the help!

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.