Results 1 to 7 of 7

Thread: getting value from the url

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2002
    Location
    Viet Nam
    Posts
    142

    getting value from the url

    I want to edit a row in my database which has the testid field , so i did a list of all testid in the first page ( named edittest.php ) which contains anchors that has the format like this :http://localhost/edit.php?testid=A01 .
    "A01" is a value of the testid in my database , and i have done this , the problem i want help from you all is that what do i write in the edit.php file to get the value of the tesid from the url of the edit.php file ( in the example above is "A01") and then passing the value to the variable $testid to do a query ?
    I guess i have to use the $HTTP_POST_VARS but don;t know how to deal with it .
    Anyone have done this please help me .

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    In older PHP:
    $testid = $PHP_GET_VARS['testid'];

    In even older PHP $testid is already available.

    In modern PHP:
    $testid = $_GET['testid'];
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    Lively Member DJ P@CkMaN's Avatar
    Join Date
    Jan 2002
    Location
    Burpengary, Queensland, Australia
    Posts
    95
    Ummm.. hate to be a spoil-sport but its not $PHP_GET_VARS but
    PHP Code:
    $HTTP_GET_VARS['testid'
    There's something I've noticed in the last year or so...
    Australian's are good at EVERYTHING !!!

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    That was that uneasy feeling that I had something wrong...
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5
    Lively Member
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    96
    or turn register_globals off.

    that way you can use $testid
    without the other stuff


    but the other way is better.!

  6. #6
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    Originally posted by bekkel
    or turn register_globals off.

    that way you can use $testid
    without the other stuff


    but the other way is better.!
    uhh no that is backwards. you should never turn them ON.

    and it doesn't matter how old the php is, well to a point, but if register_globals are ON then the variable is all you need. but if OFF you need $_GET.

    and $testid is available in any version of php, just depends on if register_globals is ON or OFF

    and $HTTP_GET_VARS['testid'] is deprecated and shouldn't be used.

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Turning register_globals on is discouraged for security reasons. But in very old PHP there wasn't a register_globals option AFAIK.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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