SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    runat="server" Golgotha's Avatar
    Join Date
    Nov 2001
    Location
    Colorado
    Posts
    2,085
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Get queryString values?

    What's the proper way to get query string params in PHP 5?
    Below is my .NET code...

    try
    {
    if(Request.Params["PrimaryID"] != null)
    {
    nPrimaryID = Request.Params["PrimaryID"];
    }
    else
    {
    nPrimaryID = "-1";
    }
    }
    catch
    {
    nPrimaryID = "-1";
    }

  2. #2
    Pandora Tipem's Avatar
    Join Date
    Feb 2006
    Posts
    450
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mytestfile.php
    PHP Code:
    $avariablehere $_GET['myquerystring'];
    echo 
    $avariablehere
    If you visited mytestfile.php?myquerystring=thisandthat the page output would be 'thisandthat.' Also, don't trust a user's input, you'll want to sanitize this variable and make sure it's safe (e.g., escape certain characters) before running any commands (particularly SQL queries). But yeah that's the basic thing.
    Tipem no fancy sig, yup
    Need Neopets Help? Try Neopets
    fun adoptable eggs


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
  •