Results 1 to 4 of 4

Thread: Display info of a logged_in user

  1. #1
    Join Date
    Nov 2005
    Location
    Austin TX,US
    Posts
    71
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Display info of a logged_in user

    Hi,
    Again with login page. I have:

    1/ login: an html form [with username/password fields]
    2/ login_check.php: to validate the username/password against db, if correct then setcookie, and go to 3/ member_only.php.:
    How do I make a simple greeting in 3/, say: Welcome <?php print $username; ?>!

    All I know so far is in 2/ I can set:
    $username=$_POST["username"];
    and refer to $username whenever I want to within 2.

    But in 3/ I don't know how, because there's no $_POST...

    Because I don't know to display that "Welcome...," I don't know how to show/display all info [query from db] related to that user either.
    Thanks very much for help!

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Get the info from that cookie you set.
    Although I'd advise using sessions, not cookies, here.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Nov 2005
    Location
    Austin TX,US
    Posts
    71
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Stumbling and not yet know how to do:

    If in 2/ I set:
    Code:
     setcookie('log',$username,time()+3600);
    and in 3/ I check cookie:
    Code:
    <?php
    require ('config.php');
    if(!isset($_COOKIE['log'])){
    Header('Location:login.php');}
    ?>
    How do I say welcome [username]? Or Your email is..., your phone is....
    Thanks

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    Welcome, <?php echo($_COOKIE['log']); ?>!
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •