How to Store Old pic in Database if no new image Updated In php -
hi in form when user submit form , select no image database updated blank can me wrong in code don't have php knowledge need help
here full php code hope got wrong
i want if user not select image old image not replace blank
i try in code still got blank!
<?php include("connect.php"); if(isset($_post['submit'])) { $id = $_post['id']; $form_no = $_post['form_no']; $shop_name = $_post['shop_name']; $shop_address = $_post['shop_address']; $owner_name = $_post['owner_name']; $owner_address = $_post['owner_address']; $phone = $_post['phone']; $m_no = $_post['m_no']; $email = $_post['email']; $d_o_b = $_post['d_o_b']; $d_o_m = $_post['d_o_m']; $b_type = $_post['b_type']; $reg_no = $_post['reg_no']; $coment = $_post['coment']; $date = date('y-m-d'); $errors = ""; $plan = $_post['select']; $oldpic=$_post["oldpic"]; if($_files['image']['name'] != "" && $errors == "") { $file_name = $_files['image']['name']; $file_size = $_files['image']['size']; $file_tmp = $_files['image']['tmp_name']; $file_type = $_files['image']['type']; $file_ext=strtolower(end(explode('.',$file_name))); $expensions= array("jpeg","jpg","png"); if(!in_array($file_ext,$expensions)) { $errors="extension not allowed, please choose jpeg or png file."; } if($file_size > 2097152) { $errors ='file size must excately 2 mb'; } if(empty($errors)) { $new_file_name = uniqid().'.'.$file_ext; move_uploaded_file($file_tmp,"user/".$new_file_name); } } if(empty($errors)) { $qreury = "update members set ref_no='$ref_no',shop_name='$shop_name', form_no='$form_no', shop_address='$shop_address', owner_name='$owner_name', owner_address='$owner_address', tel_no='$phone', mobile_no='$m_no', email='$email',dob='$d_o_b',marrige_date='$d_o_m',bussiness_type='$b_type', reg_no='$reg_no',extra_note='$coment',user_pic='$new_file_name', plan='$plan',target=(select price members_plan id ='$plan') id='$id'"; $reslt = mysql_query($qreury)or die(mysql_error()); header("location:registered_members.php"); } elseif(empty($oldpic)) { $qreury = "update members set ref_no='$ref_no',shop_name='$shop_name', form_no='$form_no', shop_address='$shop_address', owner_name='$owner_name', owner_address='$owner_address', tel_no='$phone', mobile_no='$m_no', email='$email',dob='$d_o_b',marrige_date='$d_o_m',bussiness_type='$b_type', reg_no='$reg_no',extra_note='$coment',user_pic='$oldpic', plan='$plan',target=(select price members_plan id ='$plan') id='$id'"; $reslt = mysql_query($qreury)or die(mysql_error()); header("location:registered_members.php"); } } ?>
i understand problem, please let code doing. if storing null don't worry. store null , put avtar default image on file system, , can following while fetching image view you:
<img src=" <?php !empty($your-image-with-directory)?$your-image-with-directory:"upload-directory/avtar.png"?>" width="100">
Comments
Post a Comment