SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to get the user info on 2nd page from 1st page

    Hi, I have fetched the user profile fields like this:

    $getuser = mysql_query("SELECT * from users where username = '$_GET[user]'");
    $usernum = mysql_num_rows($getuser);
    $profile = mysql_fetch_array($getuser);
    I am able to fetch it on the same page but when i try to go to 2nd page it is not showing any, i have a link from the user page to his 2nd page where it should shows more about his profile....??

  2. #2
    SitePoint Wizard frank1's Avatar
    Join Date
    Oct 2005
    Posts
    1,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by surajbgl View Post
    Hi, I have fetched the user profile fields like this:


    I am able to fetch it on the same page but when i try to go to 2nd page it is not showing any, i have a link from the user page to his 2nd page where it should shows more about his profile....??
    any way i hope thing is...
    suppose in first page...u r getting some data as $_get from some earlier page where as u r not passing that varibale to second page....so may be where is error

    what u can do is
    pass value through a form as hiiden field
    form action method=post
    input type=hidden value=$_get[variable]
    just a logic

    from what i can understand

  3. #3
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    $getuser = mysql_query("SELECT * from users where username = '$_GET[user]'");

    You have to debug your script, heres a simple thing to do.

    instead of $_GET['user'] - write in a real name - actually in your query, temporarily like.

    If that works then you will know 3 things:

    1 that name actually exists
    2 your sql query is well formed
    3 your PHP after the query is working

    Couple of other pointers for you:

    $_GET[user] should be $_GET['user']

    you have not cleansed that user name before stuffing it into your sql, so you risk an sql injection attack, sort that issue out fast.

    GET items are usually automatically urlencoded, its up to your to urldecode() them.

    "Jon Riley" would become "Jon%20Riley" when he got to your database - I bet he's not in your database
    Last edited by Cups; Nov 17, 2008 at 05:31. Reason: bad link, I cant count, duh.

  4. #4
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,077
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    Also echo $_GET['user'] to make sure that you are actually getting the variable (or check the URL for it).

    You could swap for a test user and execute the query direct against MySQL to make.

    The data should be escaped:

    $_GET['user']=mysql_real_escape_string($_GET['user']);

    Though you will need to check first if magic quotes are enabled (they should now be disabled by default).
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator


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
  •