SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Dec 1999
    Location
    Southampton, Hants, UK
    Posts
    672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    stumped with GET variables

    I have a URL or:
    http://localhost/post.php?sbn=name&sbm=message

    and post.php contains:

    Code:
    <?php
    
    echo($sbn);
    echo("<br>");
    echo($sbm);
    
    ?>
    but whenever I go to the URL above - it supposed to print out the 2 variables. but instead I get:

    Notice: Undefined variable: sbn in c:\program files\apache group\apache\htdocs\post.php on line 3

    Notice: Undefined variable: sbm in c:\program files\apache group\apache\htdocs\post.php on line 5

    I know this is really simple stuff - but I'm stumped!!!! why isn't it working. Its prob really obvious and I'm being blind, and dumb lol

    cheers

  2. #2
    SitePoint Zealot itsyM's Avatar
    Join Date
    Jul 2002
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <?php
    
    echo($sbn);
    echo("<br>");
    echo($sbm);
    
    ?>
    You have to use the $_GET array to access parameters in the URL.

    Code:
    <?php
    
    echo($_GET['sbn']);
    echo("<br>");
    echo($_GET['sbm']);
    
    ?>

  3. #3
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.


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
  •