Hi every one could you please check my code in php. i have problem when i need to update my database record that including with picture, everytime i need to update i need to brow the picture again to update, if not it will overwrite the old picture and blank, So I want it optional for the picture when we update, if we no need update picture i want it still store the old image.
here is my code:
if(isset($_POST["save"])){
$sid = $_POST['sid'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$sex = $_POST['sex'];
$nationality = $_POST['nationality'];
$photo = $_FILES['photo']['tmp_name'];
$dept = $_POST['dept'];
$position = $_POST['position'];
$date = $_POST['date'];
$status = $_POST['status'];
$efile = $_POST['efile'];
if(!isset($photo))
echo "Please select the photo";
else
{
$photo=addslashes(file_get_contents($_FILES['photo']['tmp_name']));
$photo_name = addslashes($_FILES['photo']['name']);
$photo_size = getimagesize($_FILES['photo']['tmp_name']);
if ($photo_size==FALSE)
echo "that's not an image.";
}
$updateSQL = "UPDATE staff SET sid='$sid', fname='$fname', lname='$lname', sex='$sex', nationality='$nationality', photo='$photo', dept='$dept', position='$position', date='$date', status='$status', efile='$efile' WHERE sid='$_POST[hidden]'";