SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: $_GET Help

  1. #1
    SitePoint Enthusiast BMorganVA's Avatar
    Join Date
    Mar 2010
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $_GET Help

    I want to get user information from a MySQL database. When the user goes to http://domainname .com/user.php?user=USERNAME, I want "USERNAME"'s info to be displayed, but it can never do the first query, I'm not sure if it is because the is an error in the query or in the get variable. Can someone find the error or tell me what I'm doing wrong? Thanks for the help!

    PHP Code:
    <?php
    require("includes/redirect.php");
    $flatUName $_GET['user'];
    $flatSQL "SELECT Username FROM sq_users WHERE Username = '$flatUName'";
    $goSQL mysql_query($flatSQL);
    if(!
    $flatSQL) die(mysql_error());
    if(
    == mysql_num_rows($goSQL)){
        
    header('Location: '$root $logOut);
        
    mysql_close($con);
        exit;
    }
    (If you need more code, just say.)

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The result of your mysql_query call is stored in $goSQL, but you check $flatSQL (a string) for an error on the next line instead.

    Other than that, the code looks alright (aside from being vulnerable to SQL injection)... so what exactly happens?

  3. #3
    SitePoint Enthusiast BMorganVA's Avatar
    Join Date
    Mar 2010
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm currently focused on getting the basic code made. Once it is done and published, I will start getting help on updating it. I want to get good enough at mod_rewrite for more security.

    All this code does is get information from a database and store it in variables, so it can be "echoed" back as user information.

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I'm asking what the specific problem is. Presumably you posted this because you want help with something.

    Is there an error message? If not, what is happening that isn't what you expect?

  5. #5
    SitePoint Enthusiast BMorganVA's Avatar
    Join Date
    Mar 2010
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You solved the problem. It was that the page would always redirect, even if the user name type in the URL existed. I didn't know that judging the incorrect variable was the problem until you pointed it out to me.


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
  •