have 2 questions about email and pics

Discussion in 'PHP' started by dougvcd, May 25, 2007.

  1. #1
    ok i have a form which gets filled in and then gets inserted to a database
    is it possable and how for it to send me an email saying that an entry has been made

    2nd
    at the moment i have a browse button which reads off a database into a table i would like to have a picture with each entry
    i have read you cant store pics in database so what is the best way of doing this
    cheers
    Doug
     
    dougvcd, May 25, 2007 IP
  2. tutankh

    tutankh Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    #1
    Try php.net and find mail() function.

    #2
    Good way is writiting the path to pics in database and pic files in this path.

    Regards,
    M
     
    tutankh, May 25, 2007 IP
  3. projectshifter

    projectshifter Peon

    Messages:
    394
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    tutankh is on for #1, mail($to, $subject, $message, 'From: '.$from); will do what you want it to.

    #2, technically you could store an image, but it's not recommended. I don't suggest writing the database in the path at all, that increases your database size and is a little redundant (plus I've done sites that end up changing it later so it's a hassle). Store ONLY the images file name, because if the path stays the same everytime, no need to tag it on there everytime.
     
    projectshifter, May 25, 2007 IP
  4. dougvcd

    dougvcd Peon

    Messages:
    267
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    ok thanks got the email ok
    can you point me to where i can find out more about the pics thing
    cheers
    Doug
     
    dougvcd, May 26, 2007 IP
  5. projectshifter

    projectshifter Peon

    Messages:
    394
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Not sure what all you want to know. You pretty much upload it with a form, I think the proper thing to add to the form tag is enctype="multipart/form-data". Then <input type="file" name="whatever">, and in the PHP receiving file you get a $_FILES['whatever'] array. move_upload_file($_FILES['whatever']['tmp_name'], 'new/file/area/'.$_FILES['whatever']['name']); and insert $_FILES['whatever']['name'] into a database. It's a pretty simple process, although it's not a bad idea to rewrite the name of the file to prevent abuse.
     
    projectshifter, May 26, 2007 IP
  6. dougvcd

    dougvcd Peon

    Messages:
    267
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    well i am a bit confused as you said earier to put a link in database to pic
    so i made a folder called pics on server and have a jpeg in it
    what do i have to do to add the link in the database to pic
    sorry if a bit slow but new to this
    cheers
    Doug
     
    dougvcd, May 26, 2007 IP
  7. projectshifter

    projectshifter Peon

    Messages:
    394
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #7
    You would need a database table to hold the images. In this case lets call it `images`, with `id` int(11) and `name` varchar(50). You'd want to do INSERT INTO `images` (`name`) VALUES('".$image_name."') Now you've stored the image name into the database, and you can run a query to retrieve it in the future, and it corresponds to the file you've saved in a folder.
     
    projectshifter, May 26, 2007 IP
  8. tutankh

    tutankh Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Yeah. Filenames in DB is good way if You store all files in the same directory. I also store filenames in DB. Don't know why I wrote 'path'.

    Regards,
    M
     
    tutankh, Jun 10, 2007 IP