SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist jimday1982's Avatar
    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    562
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting variable from URL?

    I have a page that has a link that points to this url:

    http://sdsl1.worldwideedge.com/cgi-b...ze=2&logo_url=

    My question is, how can I get the "code=FN-SL810" from that url to use in a select statement on my inv_pop.php page? Your help is greatly appreciated!
    Jimmy Day
    Senior Systems Analyst
    Piedmont Healthcare Corporation

  2. #2
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can use $_GET like
    PHP Code:
    $code $_GET['code'];//now $code = FN-SL810 and now you can do select statement
    //ofcourse you should do addslashes or mysql_escape_string but you only asked for how to use that in a query
    $sql "select * from table where code='$code'"
    everything in the url you can get via $_GET and everything via POST you can by $_POST

  3. #3
    SitePoint Evangelist jimday1982's Avatar
    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    562
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jaswinder_rana
    you can use $_GET like
    PHP Code:
     $code $_GET['code'];//now $code = FN-SL810 and now you can do select statement
     //ofcourse you should do addslashes or mysql_escape_string but you only asked for how to use that in a query
     
    $sql "select * from table where code='$code'"
    everything in the url you can get via $_GET and everything via POST you can by $_POST
    Works like a champ - thank you very much.
    Jimmy Day
    Senior Systems Analyst
    Piedmont Healthcare Corporation

  4. #4
    SitePoint Addict trogdor1024's Avatar
    Join Date
    Oct 2004
    Location
    New Jersey
    Posts
    235
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Be sure to scrub the $_GET['code'] variable for unexpected results if you are planning on passing it right through to the database like that.

  5. #5
    It's been real... Forbes's Avatar
    Join Date
    Dec 2004
    Location
    Yorkshire, England
    Posts
    676
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by trogdor1024
    Be sure to scrub the $_GET['code'] variable for unexpected results if you are planning on passing it right through to the database like that.
    Try:
    PHP Code:
    $newVariable htmlspecialchars(addslashes($_GET['code'])); 


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
  •