Results 1 to 4 of 4

Thread: Manipulating Query String

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2004
    Posts
    49

    Question Manipulating Query String

    Hi there,

    May I know how do I detect whether there is any query string in my url?

    For example, my url is http://www.xxxx.com/napp/view.php?vid=1

    How do I display an error page when a user types in the wrong url such as:
    http://www.xxxx.com/napp/view.php (Without the ?vid=1)
    ______________________________________

    Warmest Regards,

    Lex
    ______________________________________



    :|: Don't Mess With The Predator :|:

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Manipulating Query String

    You can acces the whole query string using the following:
    PHP Code:
    $qs $_SERVER['QUERY_STRING']; 
    PHP also loads the variables in the query string into the $_GET super global array. You can check whether it was supplied by using the isset() function:
    PHP Code:
    if (! isset($_GET['vid'])) {
      
    /* error - no vid set */

    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3
    Member
    Join Date
    Dec 2004
    Posts
    59

    Re: Manipulating Query String

    just do a check on the variable vid

    eg.
    Code:
    if ( !$_GET['vid'] )
    { 
    // redirect to or show error page
    }

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Manipulating Query String

    Quote Originally Posted by pelican
    just do a check on the variable vid

    eg.
    Code:
    if ( !$_GET['vid'] )
    { 
    // redirect to or show error page
    }
    That will produce a notice if the variable doesn't exist though.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width