ok
Direktori : /home/keydecors/public_html/admin/controller/ |
Current File : /home/keydecors/public_html/admin/controller/p_update.php |
<?php //include database configuration file include("../model/dboperation.php"); $menu = mysqli_real_escape_string($mysqli, $_POST['pid']); $categoy = mysqli_real_escape_string($mysqli , $_POST['categoy']); $p_name = mysqli_real_escape_string($mysqli , $_POST['p_name']); $p_information = mysqli_real_escape_string($mysqli , $_POST['p_information']); $img1 = ""; $img2 = ""; $img3 = ""; if(!empty($_FILES['img1']['tmp_name'])) { $temp1 = explode(".",$_FILES["img1"]["name"]); $allowed = array('gif','png' ,'jpg','jpeg'); if(!in_array(end($temp1),$allowed) ) { $newfilename1 = rand(). "_".date('m-d-Y_hia') . '.' .end($temp1); move_uploaded_file($_FILES['img1']['tmp_name'],"../pro_img/".$newfilename1); $img1=$newfilename1; } } if(!empty($_FILES['img2']['tmp_name'])) { $temp2 = explode(".",$_FILES["img2"]["name"]); $allowed = array('gif','png' ,'jpg','jpeg'); if(!in_array(end($temp2),$allowed) ) { $newfilename2 = rand(). "_".date('m-d-Y_hia') . '.' .end($temp2); move_uploaded_file($_FILES['img2']['tmp_name'],"../pro_img/".$newfilename2); $img2=$newfilename2; } } if(!empty($_FILES['img3']['tmp_name'])) { $temp3 = explode(".",$_FILES["img3"]["name"]); $allowed = array('gif','png' ,'jpg','jpeg'); if(!in_array(end($temp3),$allowed) ) { $newfilename3 = rand(). "_".date('m-d-Y_hia') . '.' .end($temp3); move_uploaded_file($_FILES['img3']['tmp_name'],"../pro_img/".$newfilename3); $img3=$newfilename3; } } $sql = "UPDATE prod_details SET cate_gory = '$categoy', p_name = '$p_name', p_details = '$p_information', p_img1 = '$img1', p_img2 = '$img2', p_img3 = '$img3' WHERE p_id='$menu'"; if (!mysqli_query($mysqli,$sql)) { die('Error: ' . mysqli_error($mysqli)); } header("location:../pages/product_update.php?pro=$menu");