Looking for help in a php code

Discussion in 'PHP' started by digitalarts, Jul 26, 2009.

  1. #1
    I am looking for help with the following:

    I have a mysql table where I hv user name and password etc.
    I have another mysql table with username and user work hour, user performance rating and number of days worked.

    As soon as the user login to the site, I want to show the user his work hour till tht date, his performance ratng till that day and total number of days he has worked till tht date.

    I am using php and mysql, so how to accomplish this?

    Can some one help me with the code to accomplish this objective. I will really be glad for the help.
     
    digitalarts, Jul 26, 2009 IP
  2. bobocheez

    bobocheez Active Member

    Messages:
    403
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    55
    #2
    i dont know much about php but couldnt you use _post?

    so when the user logs in(if successful login), use post to store the username and call from that row in the 2nd table?

    dont ask me how to do this, but if you know php this might work....
     
    bobocheez, Jul 27, 2009 IP
  3. kumara1231

    kumara1231 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I can do this, what do you want, do you want me to do it , need the trainning to done by your self
    ?
    pm me
     
    kumara1231, Jul 27, 2009 IP
  4. SHOwnsYou

    SHOwnsYou Peon

    Messages:
    209
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    
    <<on the login page, after you've checked the db to make sure someone with that username and pw exists>>
    $_SESSION['user'] = $username;
    
    PHP:
    Now include this code on the page you want the stats to display:
    
    if (isset($_SESSION['user']))
    {
    $query = mysql_query("SELECT * FROM table2 WHERE username='{$_SESSION['user']}'");
    while ($row = mysql_fetch_array($query))
    {
    echo "Hello $row[username] <br />";
    echo "Your user work hour (?) is: $row[userworkhour] <br />";
    echo "Your user rating is: $row[userrating] <br />";
    echo "Your total days worked is: $row[daysworked]";
    }
    }
    
    PHP:
     
    SHOwnsYou, Jul 27, 2009 IP
  5. Chikey.ru

    Chikey.ru Peon

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    if user login == true
    select * from table2;
     
    Chikey.ru, Jul 27, 2009 IP
  6. Chikey.ru

    Chikey.ru Peon

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    SHOwnsYou thanks, this is code what i want to suggest.

    1. but i think you should using primary key instead username for security and convenience
    $_SESSION['userid'] = $id;

    2. if (isset($_SESSION['user']))
    you can easy using if ($_SESSION['user']) effect will be identity
     
    Chikey.ru, Jul 27, 2009 IP
  7. chanakya

    chanakya Peon

    Messages:
    361
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    chanakya, Jul 27, 2009 IP
  8. digitalarts

    digitalarts Peon

    Messages:
    105
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    @ shownyou and chikey.ru

    I am confused between both of urs suggestion.

    @chikey.ru could you please be more specific?
     
    digitalarts, Jul 27, 2009 IP