Advanced Search

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: URL filtering varables

  1. #1
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Question URL filtering varables

    Hello,
    I am going to get straight to the point without explaining my life story(site story) and problems(as I am known for).
    How do you strip a url from its ?a-var=b-value&d-var=c-value I have used: $_SERVER['PHP_SELF'], but that returns all the passed on varables. Can someone show me a simple script for this. Thanks,
    FSD.

    Edit: Fixed formatting.
    Last edited by tech_support; 11-11-2007 at 08:13 AM.
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I'm not sure what you mean.
    Code:
    $url = 'http' . (empty($_SERVER['HTTPS']) ? '' : 's') . '://' . substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], '?'));
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    It worked, but I had to add $_SERVER['SERVER_NAME'] so that the full url showed up. I am having second thoughts about this. The whole point was to just add ?skip=yes to the url. This is for the Validator. When the script sees that skip=yes it skips the whole cookie setting page, which is not the actual page being validated. So why just not add &skip=yes to the end? well W3's validator does not like it, it wants you to "encode" it to & It gave a link to a page because sooo many of these perfictly valid pages were getting turned down, and it said to change the seaporator in URL's!?!? There has got to be an eaiser way, plus I cannot change the php.ini file to even make the change.
    And sometimes its a completly different page without the passed on varible. HELP!
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It worked, but I had to add $_SERVER['SERVER_NAME'] so that the full url showed up.
    Whoops, yes, missed that.
    The whole point was to just add ?skip=yes to the url. This is for the Validator. When the script sees that skip=yes it skips the whole cookie setting page, which is not the actual page being validated.
    Why not just set the cookies on the actual page?
    So why just not add &skip=yes to the end? well W3's validator does not like it, it wants you to "encode" it to & It gave a link to a page because sooo many of these perfictly valid pages were getting turned down, and it said to change the seaporator in URL's!?!? There has got to be an eaiser way, plus I cannot change the php.ini file to even make the change.
    You misunderstood it. Often, site authors have a link like this:
    Code:
    <a href="somepage.php?a=1&b=2">Click!</a>
    This is not valid HTML, because the & symbol indicates the start of an entity reference like &nbsp; or &aumlaut;. Instead, you're meant to escape the & symbol:
    Code:
    <a href="somepage.php?a=1&amp;b=2">Click!</a>
    This results in the same URL, but is safely embedded in the HTML. Because this can be a bit of a hassle, the W3C recommends that scripts use the semicolon character instead, which is perfectly valid according to the CGI specification:
    Code:
    <a href="somepage.php?a=1;b=2">Click!</a>
    Unfortunately, PHP is notoriously lax about following this specification, and doesn't support it by default: you have to enable it in php.ini or parse the query string yourself. The easiest solution is probably just to use &amp;.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    Code:
    <a href="somepage.php?a=1&amp;b=2">Click!</a>This results in the same URL, but is safely embedded in the HTML. Because this can be a bit of a hassle, the W3C recommends that scripts use the semicolon character instead, which is perfectly valid according to the CGI specification
    1.So what your saying is that I can use &amp; and It wont Effect the code? If so, I have already started to write a function called url("the.url.com", "to return value or make a link", "any attributes to add to the <a> tag"); and now I will add "to encode or not" which would use what function? Is it like htmlspecialchars() or somthing? Maybe I can use the hex value or somthing(or whatever the name is for %20 being "space").
    2."Because this can be a bit of a hassle..."
    Not at all, with my url encoder.
    Why not just set the cookies on the actual page?
    2 words:
    L O N G S T O R Y
    The topic that I posted for that issue was well over 20 posts total
    Last edited by fileserverdirect; 11-08-2007 at 07:54 PM.
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    htmlspecialchars() will do just fine.
    Maybe I can use the hex value or somthing(or whatever the name is for %20 being "space").
    That's URL encoding, and isn't what you want to do here. You need to escape & for use in HTML, but URL encoding is a form of encoding targetted at the HTTP protocol.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    A bit of a problem...
    But first, the &amp; worked, the page is valid! But wait, it's not validating &skip in the url. It thinks that the amperstand is part of W3's url!!! Not mine! I have even tried &amp;amp; in the url, but it still does not work! Help.
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    What are you talking about? :-\ I'll need to see the offending link.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    I guess I was a little vauge,

    What I am trying to say is that It thinks that the amperstand in my url, that's being submitted, is being translated to being part of W3's url. For example:
    Code:
    http://validator.w3.org/check?uri=www.mysite.com/tests/whatever/index.php?w=1056&skip=yes
    The validator is taking skip=yes and putting it part of it's own url, so it's only validating:
    Code:
    http://validator.w3.org/check?uri=www.mysite.com/tests/whatever/index.php?w=1056
    and thinking &skip=yes is for the validator! I have tried the following, and it ethier did not work at all, or validated a differant page because of it:

    &amp;ampskip=yes
    %26amp;skip=yes
    %26skip=yes
    %2526skip=yes
    &amp;skip=yes
    %26amp;amp;skip=yes
    %2526amp;amp;skip=yes
    I hope you understand now what the problem is.
    Thanks,
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  10. #10
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    There you do need to URL-encode it:
    Code:
    http://validator.w3.org/check?uri=http%3A%2F%2Fwww.mysite.com%2Ftests%2Fwhatever%2Findex.php%3Fw%3D1056%26skip%3Dyes
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •