[SOLVED] rtim function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
drgnjucr
Forum Commoner
Posts: 30
Joined: Thu Jan 27, 2005 3:06 pm
Location: NJ
Contact:

[SOLVED] rtim function

Post by drgnjucr »

Would anyone know how I can grab just a portion of my url string?

Here is the url I am working with:

Code: Select all

http://localhost/uilogin.php?authID=1&uid=drgnjucr&url=secured.php
I want to rtrim (or any other way) so all I return is the pagename. In my example, I'm looking to return just "secured.php"

I was trying something like this:

Code: Select all

$pageName = rtrim($_SERVERї'QUERY_STRING'],'url=');
It didn't work, and I'm not sure how to do this. Any help would be appreciated.


Thanks!
Mike
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

cob05
Forum Newbie
Posts: 3
Joined: Tue Jan 25, 2005 11:18 pm

Post by cob05 »

This should work for you:

Code: Select all

$pageName = $_REQUESTї'url'];

echo "The pagename is: $pageName";
drgnjucr
Forum Commoner
Posts: 30
Joined: Thu Jan 27, 2005 3:06 pm
Location: NJ
Contact:

Post by drgnjucr »

Thanks for the reply.
I was about to post a comment saying I fix my issue... cause I did, but I found a different fix other than what you have suggested.

Code: Select all

$qs = $_SERVERї'QUERY_STRING'];
			if (strpos($qs, 'url=') !== false) {
			  $_SESSIONї'pageName'] = $qs;
			}
If there any prefered method? Or basically what ever works! :)
So, my issue is fixed, but if there is a better practice as to how I should acomplish my goal; I'd rather do it that way.

Mike
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

$_GET is the oft used method, as it's simple and already parsed for you.
drgnjucr
Forum Commoner
Posts: 30
Joined: Thu Jan 27, 2005 3:06 pm
Location: NJ
Contact:

Post by drgnjucr »

I'm not sure that I can use $_GET here, because I'm posting data back to the page. It's my login page and I'm doing a bunch of stuff on it.

At any rate, I'm gunna say my issue is fixed. :)

Thanks for all the input from all!

Mike
Post Reply