Whole mess of crap to deal with, try to stay with me here...
The server I'm working with doesn't allow any htaccess changes, so to keep URLs somewhat user-friendly, I'm extracting the query string, and using what's in there as a variable, rather than full-out URL variable passing.
i.e. ?home instead of ?page=home
That much I have set up without a problem. The problem is when there is another variable in the query string (which happens if someone wants to switch the stylesheet). The query string ends up looking like this:
?home&s=1
It picks up s=1 okay, but doesn't know what to do with home, and the query string is taken as "home&s=1," which isn't a valid page, obviously. What I want to do is have it find "home" (I suppose it would consider this a variable without a value).
Having very little experience with regular expressions, I'm not sure if they have the capability I'm looking for (although, from what I understand, it makes sense that they would). What I'm asking is, how would I set up the expression to search for an unknown value?
Lot of explanation for one question, huh?
To regex, or not to regex?
Moderator: General Moderators
You could have a query string like:
http://www.mysite.com/index.php?page=forum/posts/233/2
Explode $_GET['page'] to grab the args.
As well as making URLs more user friendly, parsing the query string makes it harder for tamperers to glean the function of each GET var.
http://www.mysite.com/index.php?page=forum/posts/233/2
Explode $_GET['page'] to grab the args.
As well as making URLs more user friendly, parsing the query string makes it harder for tamperers to glean the function of each GET var.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
You could also grab everything before the first & (check the user comments):
http://php.net/manual/en/function.strstr.php
Mac
http://php.net/manual/en/function.strstr.php
Mac