SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Addict
    Join Date
    Jun 2007
    Location
    Plymouth uk
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question need some advice on how to achive this

    ok at the moment i have the form for them to submit details to my database
    and another form for them to upload a photo if they have one
    what is the best way to get the photo and database name of photo to match
    by renameing photo and database field to match
    eg the databse id = say 1 so pname = 1 and photo would be 1.jpg ond so on
    if you see what i am trying to do
    cheers
    Doug
    Last edited by dougvcd; May 10, 2009 at 10:53. Reason: more info
    an old man of 60 trying to keep up with the youngsters he he
    http://lostpetsplymouth.net16.net

  2. #2
    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)
    Smplest way might be that if their id number is 23 and you have an image called "23.jpg" in an images folder, then display it.

    PHP Code:
    $id 23 // from somewhere ...

    // later, when outputting their record

    if( file_exists'/images/' $id '.jpg' 
       echo 
    '<img src="/images/' $id '.jpg" />' PHP_EOL 
    If your user has uploaded a file and you moved it to the images folder, and assigned it their default user id, and it is found, then display it.

    Thats a quick and dirty method which will work fine, and you don't need to frig with your database.

    You might want to flag its existence in the dbase later, or get an alt text, or a title or an upload date, or have more than one photo .... later eh?

  3. #3
    SitePoint Addict
    Join Date
    Jun 2007
    Location
    Plymouth uk
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey buddy thanks for reply have had a bit of a think (no it didnt hurt)
    is there a way that when they fill out form i can assign to field pname the id that they will have in database or does that not get assigned untill its sent to database
    if you see what i mean
    cheers
    Doug
    an old man of 60 trying to keep up with the youngsters he he
    http://lostpetsplymouth.net16.net

  4. #4
    SitePoint Addict
    Join Date
    Jun 2007
    Location
    Plymouth uk
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok thought again what i have done is asigned the pname as email address
    so when they upload a photo to the upload folder i tell them to rename it to there email address .jpg
    eg myemail@here.com.jpg

    so what i need now if they havnt uploaded a photo it will use one i have
    this is part of the code to display
    some thing like if .$info['pname'] . dosnt exist then use say doug@pet.com
    and i would have a photo with that name in upload folder

    PHP Code:
    Echo "<img src=http://www.djbcaravanhire.co.uk/uploads/".$info['pname'] ." alt=\"Image\" align=\"left\" width=\"75px\" height=\"75px\" hspace=\"10px\" vspace=\"8px\"> <br>"
    an old man of 60 trying to keep up with the youngsters he he
    http://lostpetsplymouth.net16.net

  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)
    Hi Doug, er, never seen that done before ... not to say you shouldn't but all the same check carefully that no characters can be entered into an email address that could be harmful to your OS - permitting directory traversal etc.

    Going back to the idea of using the ID, I think what you mean is that you have a single screen where new users login, so you have not yet assigned them a user id so you dont know what to call the file.

    Well the way round that might be to :

    1) ask them to register, then allow them to upload an image

    2) if it has to be done on a single screen then in the background first of all create the record, get the mysql_insert_id from a successful insert and reuse that number further down the script to assign the id number of the uploaded and moved image.

    Using mysql_insert_id will only work if your users table has an auto-increment field as its Primary Key.

    There is so much to go wrong with uploads though, that I must say I would tend to split up the responsibilities to 2 screens and tell them.

    Step 1: Register with us
    Step 2: Upload an image of the lost pet
    Step 3: Create a poster

  6. #6
    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)
    v.nice doug, bravo.

    Couple of usability suggestions that are only personal taste, but seeing as you asked:

    Move "about us" onto its own page and unclutter the home page even more.

    Make 2 big links

    Report a lost cat | Report a lost dog.

    (the Main Thing is to keep the Main Thing the Main Thing) The word "Report" on its own is too ambiguous IMO. "Report lost pet" on your menu would be more explicit.

    Make those chosen links then preselect the form elements:

    report.php?type=dog
    report.php?type=cat

    So that if they picked dog the dog is preselected in your drop menu.

    maybe later:
    report.php?type=other

    Its pretty easy to do. Ask if unsure.

    maybe later:
    report.php?type=other

    When viewing the lost cat, I wanted to see a bigger version of the picture, and couldn't see where I did that.

  7. #7
    SitePoint Addict
    Join Date
    Jun 2007
    Location
    Plymouth uk
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cheers for your comments
    have implimented some of them if you want to see
    the only thing i am unsure is about making photos bigger
    thanks
    doug
    an old man of 60 trying to keep up with the youngsters he he
    http://lostpetsplymouth.net16.net

  8. #8
    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)
    Well if you are strict about your 200 x 200 rule, you can show them all on one page.

    So at some stage you might want thumbnails and a summary [link to] A full page with bigger photo ( and that doubles as your "poster" with a special print.css file).

  9. #9
    SitePoint Addict
    Join Date
    Jun 2007
    Location
    Plymouth uk
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i like the idea about thumbs and bigger pics
    where do i go to read how to do it
    cheers
    Doug
    an old man of 60 trying to keep up with the youngsters he he
    http://lostpetsplymouth.net16.net

  10. #10
    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)
    Ahh, now you're asking.

    Your server needs to have a graphics library installed (GD or PhotoMagic) just search for "image resizing php" or thumbnails.

    No doubt there are a few SP tutorials on that too.


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
  •