Quick Question regarding image names stored in Mysql DB
Posted on 2004-08-19
I have a form where people can upload data and an image to a db. If they do not upload an image, they can edit their entry later and add an image then.
However (and this is the issue) if they add an image and THEN go and edit the details, it deletes the image name from the db, this is because if they do not upload an image when they edit the form, it submits $_POST['image'] (as a hidden form variable) to the db, but if they DO upload an image it submits $pic_name. Now, because in my INSERT/UPDATE staements, for the column 'image' I have specified $pic_name to be INSERTed/UPDATEd... does this make sense? Its kinda hard to summarise... Basically, I need to create an if statement (maybe?) that says that if no image is uploaded, to INSERT/UPDATE $_POST['image'] or if an image is uploaded, to INSERT/UPDATE $pic_name.....
sheeesh ! does that make sense?