name : setting_images4.php
<?php 
include('../config/config.php');

$q            = $_POST['q'];
$pro_name     = $_POST['pro_name'];
$file1        = $_FILES['file1']['tmp_name']; 
$file2        = $_FILES['file2']['tmp_name']; 



$sql = "SELECT * FROM projects WHERE p_id = ".$q." ";
$res = $conn->query($sql);
while($row = $res->fetch_assoc()){
    $im_show = $row['p_im_show'];
    $check_path = substr($im_show,7,32);
}


$sql  = "SELECT * FROM project_details WHERE p_pd_id = ".$q." ";
$res = $conn->query($sql);
$num_rows = $res->num_rows;
if($num_rows >= 5) {
    echo 3;
}else{
    if(isset($_POST['text_image1']) !== ""){
        $text_image1        = $_POST['text_image1']; 
        $images = $_FILES['file1']['tmp_name'];
        $images_name = $_FILES['file1']['name'];
        $images1 = "upload/".$check_path."/".md5($date_current.$_FILES['file1']['size'].rand(1,1000000).time()).$images_name;
        move_uploaded_file($_FILES['file1']['tmp_name'],"../".$images1);
        $sql1 = "INSERT INTO project_details (p_pd_id,im_pd_id,pd_position,pd_no,pd_text) VALUES (".$q.",'".$images1."',12,1,'".$text_image1."')";
        $res1 = $conn->query($sql1);
    }else{
        $images = $_FILES['file1']['tmp_name'];
        $images_name = $_FILES['file1']['name'];
        $images1 = "upload/".$check_path."/".md5($date_current.$_FILES['file1']['size'].rand(1,1000000).time()).$images_name;
        move_uploaded_file($_FILES['file1']['tmp_name'],"../".$images1);
        $sql1 = "INSERT INTO project_details (p_pd_id,im_pd_id,pd_position,pd_no) VALUES (".$q.",'".$images1."',12,1)";
        $res1 = $conn->query($sql1);
    }
  

    if(isset($_POST['text_image2']) != ""){
        $text_image2        = $_POST['text_image2']; 
        $images = $_FILES['file2']['tmp_name'];
        $images_name = $_FILES['file2']['name'];
    
        $images2 = "upload/".$check_path."/".md5($date_current.$_FILES['file2']['size'].rand(1,1000000).time()).$images_name;
        move_uploaded_file($_FILES['file2']['tmp_name'],"../".$images2);
        $sql2 = "INSERT INTO project_details (p_pd_id,im_pd_id,pd_position,pd_no,pd_text) VALUES (".$q.",'".$images2."',12,2,'".$text_image2."')";
        $res2 = $conn->query($sql2);
    
    }else{
        $images = $_FILES['file2']['tmp_name'];
        $images_name = $_FILES['file2']['name'];
    
        $images2 = "upload/".$check_path."/".md5($date_current.$_FILES['file2']['size'].rand(1,1000000).time()).$images_name;
        move_uploaded_file($_FILES['file2']['tmp_name'],"../".$images2);
        $sql2 = "INSERT INTO project_details (p_pd_id,im_pd_id,pd_position,pd_no) VALUES (".$q.",'".$images2."',12,2)";
        $res2 = $conn->query($sql2);
    
    }

  

    if(($res1 === true) and ($res2 === true)){
        $sql = "UPDATE projects SET p_status= 1 WHERE p_id=".$q ."";
        $res = $conn->query($sql );
        if($res === true){
            echo 1;
        }else{
            echo 0;
        }
    }else{
        echo 0;
    }
    
}
?>

© 2024 UnknownSec