SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Oct 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    URL Query String Wont Work

    Hello,

    Yes, I have searched this forum. Yes, I have searched the stickies.

    I am new. And undoubtedly the problem here is in front of the keyboard. I am following Kevin Yank's very nice beginners guide to MySQL and PHP. Here is the specific page I have a problem with. http://dev.mysql.com/tech-resources/...s/ddws/17.html

    I have copied and pasted directly into the file and still cant get any value returned. The url query that is in the HTML looks like this,
    Code:
    <A HREF="welcome.php?name=Kevin"> Hi, I'm Kevin! </A>
    The PHP like this,
    Code:
    <?php
      echo( "Welcome to our Web site, $name!" );
    ?>
    The non working example is here: http://pixelsnot.com/db_test_site/hi.html.

    I hope this easy enough for someone here. I'm sure it is. Thank you very much for your time.

    My server is running PHP 5.2.17

  2. #2
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,343
    Mentioned
    192 Post(s)
    Tagged
    4 Thread(s)
    There is some code you are not showing (or it is missing).
    I no longer own that book - so cannot reference the page precisely - but you need to capture the GET parameter like this (above the code you posted)
    Code:
    <?php $name = $_GET['name']; ?>
    Is there a paragraph in the book you missed? Did two pages stick together?

    HTH
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Git is for EVERYONE
    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains

  3. #3
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    It's quite possible that the book, if it's an older copy, might be using register_globals, which is evil, old and deprecated. Whatever you do, don't ever turn register_globals on. It will ruin your life and demand the soul of your first-born.

    Register_globals makes all GET, POST, COOKIE fields available in your script as regular variables. While this seemed handy at first, it turns out it's a major security hole, which eventually lead to thousands of sites being defaced/ hacked.

    As ParkinT shows, you need to specifically retrieve the variable you need from the superglobals it's in (GET, POST, COOKIE, ENV etc).

    Edit>>
    Just noticed you're using an online version of the guide. You might need to find an updated version of the guide, as this is a very very old version.

  4. #4
    SitePoint Member
    Join Date
    Oct 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks above!

    I am familiar with turning register_globals off in a few projects. Since the guide isn't dated I wasn't sure if the world of PHP had changed around the tutorial. And that does indeed seem to be the case.

    I used the _GET param and it worked great. Thank you. I will tread carefully though the rest of this lesson with an understanding that it is dated.

    Thank you both very much for the help.


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
  •