Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get data from url without sting= 1

Status
Not open for further replies.

y2k1981

Programmer
Aug 2, 2002
773
IE
I've seen this done on a site, but can't figure out how. Basically instead of saying viewuser.php?userid=1, the URL simply reads viewuser.php?1. How do you read that 1 from the URL, I've tried $get = $_GET[*], I've tried it without the * but nothing works. how is it done, surely it's not THAT difficult !?!?!?
 
That's usually an indication of mod_rewrite().

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
I haven't read alll of the link that you posted, but that appears to be an apache module. this is simply where you can replace myphpfile.php?string=12345 with just myphpfile.php?12345 - it's not rewriting a URL or anything, I just want to know how you go about using PHP to read the 12345 from $_GET without the 'string' variable being there. I don't think this is an apache thing, can you help at all?
 
Perfect, that's exactly it. Thanks so much, it was really buggin' me !!!!
 
I understand that. Follow my thinking:
1. query string is "1"
2. $_GET['1'] is set
3. Extract the value by getting the key

 
DRJ478:
Wont this cause extra load on the system, rather than using the existing function for retrieving the querystring?

I however see that your example can be usefull for gathering a bit of a querystring, or something in that way.

ps. I dont mean to be rude, I just ask to gain my personal knowledge.

Olav Alexander Mjelde
Admin & Webmaster
 
DaButcher
Your suggestion for using the $_SERVER['QUERYSTRING'] is good. I just wanted to point out that there is an alternate - not necessarily better - way to gather the same information.
I would not worry about the extra load for that line of code - if I had to, I'd scrap my system and upgrade to a 80486 processor ;)
 
drj478:
yeah, if you run dedicated server, it's no issue whatever you do. I ran some servers with some friends of mine, PIII 600EB, PIII 450, etc. dedicated cs server, dedicated shell, dedicated web.

we gave free accounts to people, but we clost it down because of all the whining of people who wanted to play cs, when we had to update the server.

I gave away all the "old" computers and now the slowest pc here, is the one im using for programming and some gaming, my p4 2.8HT with a bit better than avg. hw.

I dont run any servers though, as I find it's better to rent hosting, so I can be the one to whine, when something does not work as I want it to do, when I want it to do.

I find this fact very pleasant! Even though I've built and repaired computers since the age of 12, I do not actually like fixing old hw, as I think it's boring.

I guess this is enough offtopic for now, so good night all.

Olav Alexander Mjelde
Admin & Webmaster
 
You can also explode the string into an array.

So if your string is file.php?r=1&x=2 you can make it file.php?1,2

So pretty much you just explode the uri and remember which array variable is which.

You can also use mod_rewrite and make it seem like all the variables are directory like journal/2004/10/12/this_is_the_title
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top