SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,104
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Post user login picture

    Hi, I need some help to you, i want to know how can i do this,when after the user login.I want that to put picture besides his name just like the same in the facebook after we login..can you help me please how can i do this.

    example:

    Welcome <img> jemz.


    Thank you in advance.

  2. #2
    SitePoint Member
    Join Date
    Jul 2012
    Location
    California, USA
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello there.

    Where exactly do you want this image to be displayed?
    Facebook displays the user's image beside their name in the top-most bar (next to navigation).
    Are you trying to do the same?

  3. #3
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,104
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Sheegoth View Post
    Hello there.

    Where exactly do you want this image to be displayed?
    Facebook displays the user's image beside their name in the top-most bar (next to navigation).
    Are you trying to do the same?
    Yes, just like that.can you help me please i have no idea on this.I hope you can help me.thank you in advance.

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    ok so you need a few things in place before this will happen.

    1/ give the user an upload form so they can upload their image.
    2/ resize the image to fit with your dimensions
    3/ store the filename in the database table along with the other user information.
    4/ query the database to get all the user info including the image name.
    5/ add the image tag to the users profile and display the image that is stored on your server.

    or

    use gravatar.....
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  5. #5
    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)
    Make sure every login is unique, and to make is easier make sure each login only contains characters which are allowed in a valid file name.

    I know, like jemz or Cups

    then when they upload their image, name it after their user name.

    "Hi there jemz, here is your picture []"
    PHP Code:
    <?php

    if( !isset($_SESSION['username']) )
      
    // send away to login

    $username $_SESSION['username'];

    // do some kind of data cleansing here 
    // disallowing directory traversal attacks
    // being aware a clever user could add dots and slashes
    // to their original user name

    echo "Hi there $username,"

    // make sure the file exists 
    if( file_exists('/user-images/' $username'.jpg'))
        echo 
    ' here is your picture <img src="/user-images/' $username  'jpg" />';

    ?>
    This is just an incredibly simplified example of how you could go about things ie username === image name plus .jpg, but you have to be very very careful to defend against simple attacks - as my comments hopefully show, I have no idea how clean or "tamper-able" the data getting to your SESSION is.

  6. #6
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Let users upload their pics, save the path to the pics in db column, say, image_column


    You login query should do something like this:

    $sel = select image_column from users_table where username='$user_name' limit 1

    $row=mysql_fetch_assoc($sel)

    $_SESSION['path_to_image'] = $row['image_column']

    ................................................................................................
    Then in the member area:

    $path_to_image = $_SESSION['path_to_image']

    echo "<img src='$path_to_image'>" anywhere you want the image to appear.


    Note these are just code ideas, not actual code.

  7. #7
    SitePoint Wizard
    Join Date
    May 2012
    Posts
    1,104
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    @spikeZ,@Cups,@tentim...Thank you for giving this idea.okay i will try to make a simple upload form...but i have question what if the uploaded picture is 500x400 and then how can i resize this to display it to 23px or just the same the size in the facebook...Thank you in advance.

  8. #8
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Have a look for a simple upload and resize script jemz. There are plenty around and they will upload the picture to your server and then resize it to the width/height you tell them.
    Whatever you do DO NOT upload a 500px wide picture and then use the browser to squash it down to 23px!!!!
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  9. #9
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I use phpThumb for such things.


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
  •