SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    getting images from folder using session

    i created a folder for images. i want my program to be like this, if the user entered his username and password, his picture will be displayed to the index page.

    my question is, what syntax should i use to access or get the jpg file to be displayed in the index page

    tnx

    hleigh

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You don't give us much information so I'll have to presume some things -

    You have a database
    You have a users table
    You have a field in the users table which holds the image name
    You can deal with the login procedure

    It's really quite simple

    $image = '/path/to/your/web/dir/people_images/'.$imageNameFromDB;
    if(file_exists($image)) {
    echo '<img src="'.$image.'" alt="Photo of '.$username.'">';
    }

    These are the bones of what you need, you should perhaps create a default image for those people who don't have an image and add that as an 'else' statement. You should also have some way of handling height and width, either by dynamically calculating them with get_image_size() or storing them in the database when the photo is added.

    HTH

    Andrew


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
  •