PHP/MySQL programming?

Discussion in 'PHP' started by sonjeriff, Oct 22, 2010.

  1. #1
    hi , ive made a member profile page and i want to grab the member data from the mysql table and display it on the page.

    i want to grab the data from the row associated with the member logged in.

    thanks.
     
    sonjeriff, Oct 22, 2010 IP
  2. lowridertj

    lowridertj Well-Known Member

    Messages:
    2,882
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    195
    #2
    Details of database table? Please let me know the information stored int eh table. A Export of the tables rows will help. then I can generate the mysql query and show how you can pull the data..
     
    lowridertj, Oct 22, 2010 IP
  3. max2010

    max2010 Greenhorn

    Messages:
    81
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    something like this:

    $username=''; // comes from some post (needs to be sanitized)
    $password=''; // comes from some post (needs to be sanitized)

    ...
    ...

    $user_query = mysql_query("select * from users where username='".$username."' AND password='".$password."';");

    if (!mysql_num_rows($users_query)) {
    $error = true; // nobody with this username or password doesn't match (is better not to tell the right error to users)
    }
    else {
    $user_data = mysql_fetch_array($user_query);
    }

    if (!$error) {

    echo $user_data['username'];
    echo $user_data['address'];
    ...
    ...

    }
    else {

    echo '<p>Username or password doesn\'t match</p>';
    ...
    ...

    }
     
    max2010, Oct 22, 2010 IP
  4. betaturn

    betaturn Peon

    Messages:
    273
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You need to have a name of database, then connect to database. Then select a row, then display the result.
     
    betaturn, Oct 23, 2010 IP
  5. flight05

    flight05 Active Member

    Messages:
    122
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    61
    #5
    Yeah....... Ill help you out.
     
    flight05, Oct 23, 2010 IP