0xV3NOMx
Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64



Your IP : 3.22.42.25


Current Path : /var/www/html/gcg/adm/admin/src/
Upload File :
Current File : /var/www/html/gcg/adm/admin/src/saveeditapp.php

<?php
	
	include ("database.php");
	$fappno = $_POST['gappno'];
	$user = $_SESSION['USERTYPE'];
    $updatevalue = $_POST['updatevalue'];
    $studsub = $_POST['studsub'];   
    $per_arr_data = json_decode($updatevalue, true); 
    $studsub = json_decode($studsub, true);    
   
    $rgPerArray = array();
    $subcode = array();


    $query2= "SELECT  ifnull(FDEGREE,'') as FDEGREE,ifnull(FEXAMNO,'') as FEXAMNO,
            ifnull(FAPPNO,'') as FAPPNO,ifnull(FCOLLCODE,'') as FCOLLCODE,
            ifnull(FSLNO,'') as FSLNO,ifnull(FDELETED,'') as FDELETED,
            ifnull(FAYEAR,'') as FAYEAR
            FROM studadm WHERE fappno ='{$fappno}' ";            
    $result2 = mysqli_query($conn,$query2);
    $app['studdet'] = mysqli_fetch_all($result2,MYSQLI_ASSOC);

    $fdegree = $app['studdet'][0]["FDEGREE"];
    $fexamno = $app['studdet'][0]["FEXAMNO"];
    $fappno = $app['studdet'][0]["FAPPNO"];
    $fcollcode = $app['studdet'][0]["FCOLLCODE"];
    $fslno = $app['studdet'][0]["FSLNO"];
    $fdeleted = $app['studdet'][0]["FDELETED"];
    $fayear = date('Y');
    // var_dump($fdegree,$fexamno,$fappno,$fcollcode,$fslno,$fdeleted,$fayear);

    $query3 = "SELECT ftotsub FROM degree WHERE fdegree = '$fdegree' AND fexamno = '$fexamno'";
    $result3 = mysqli_query($conn,$query3);
    $app['totsub'] = mysqli_fetch_array($result3,MYSQLI_ASSOC);
    
    $totsub = $app['totsub'];

    for($i=0;$i<count($studsub); $i++){
        // $subcode[$studsub[$i]['value']];
        array_push($subcode, trim($studsub[$i]['value'], '"'));
    }
    
    // echo trim($subcode, '"');
    
    // var_dump($subcode);
    // var_dump($studsub);
    // var_dump($studsub[0]['value']); 
    // var_dump($totsub);
    $studsubcnt =count($studsub);
    $totsubcnt = (int)$totsub['ftotsub'];

    // var_dump($studsubcnt,$totsubcnt);
    if($totsubcnt == $studsubcnt){


        // var_dump('delete');

        $query4 = "delete FROM options WHERE fdegree = '$fdegree' AND fcollcode = '$fcollcode' AND fappno = '$fappno' AND fexamno = '$fexamno'";
        $result4 = mysqli_query($conn,$query4);

        for($i=0; $i < $studsubcnt; $i++){
            
            $query5 = "INSERT INTO `options` (`FDEGREE`, `FEXAMNO`, `FCOLLCODE`, `FSLNO`, `FSUBCODE`, `FDELETED`, `FYEAR`, `FAPPNO`, `FREGNO`)
            VALUES
            ('$fdegree', '$fexamno', 
            '$fcollcode', '$fslno', 
            '$subcode[$i]', 'F', 
            '$fayear', '$fappno', '')";
            // var_dump($query5);
            $result5 = mysqli_query($conn,$query5);



        }
        // echo('sub updated');
    
    }else{
        // var_dump('else cond');
        $row['status'] = 'failure'; 
		$row['msg'] = 'Updation of subjects Failed';
		echo json_encode($row);
    }



	for($i=0; $i<count($per_arr_data); $i++)
	{
		$rgPerArray[$per_arr_data[$i]['id']] = $per_arr_data[$i]['value'];

    }
    // var_dump($rgPerArray);
    // die();
	$query = "update studadm set
		FNAME = '{$rgPerArray['FNAME']}',
		FFATNAME = '{$rgPerArray['FFATNAME']}',
		FMOTNAME = '{$rgPerArray['FMOTNAME']}',		
		FRELIGION = '{$rgPerArray['FRELIGION']}',
		FCASTE = '{$rgPerArray['FCASTE']}',
        FSUBCASTE = '{$rgPerArray['FSUBCASTE']}',
        FDOB = date_format(STR_TO_DATE('{$rgPerArray['FDOB']}','%d/%m/%Y'),'%Y-%m-%d'),
		FAADHARNO = '{$rgPerArray['FAADHARNO']}',
		FPERMADD1 = '{$rgPerArray['FPERMADD1']}',
		FPERMADD2 = '{$rgPerArray['FPERMADD2']}',
		FPERMADD3 = '{$rgPerArray['FPERMADD3']}',
		FPERDISTRICT = '{$rgPerArray['FPERDISTRICT']}',
		FPERPINCODE = '{$rgPerArray['FPERPINCODE']}',
		FPERSTATE = '{$rgPerArray['FPERSTATE']}',
		FCURRADD1 = '{$rgPerArray['FCURRADD1']}',
		FCURRADD2 = '{$rgPerArray['FCURRADD2']}',
		FCURRADD3 = '{$rgPerArray['FCURRADD3']}',
		FCURDISTRICT = '{$rgPerArray['FCURDISTRICT']}',
		FCURPINCODE = '{$rgPerArray['FCURPINCODE']}',
		FCURSTATE = '{$rgPerArray['FCURSTATE']}',
		FCONTACT_NO = '{$rgPerArray['FCONTACT_NO']}',
		FLANDLINE = '{$rgPerArray['FLANDLINE']}',
		FEMAIL = '{$rgPerArray['FEMAIL']}',
		FBANKACNO = '{$rgPerArray['FBANKACNO']}',
		FBANKBRANCH = '{$rgPerArray['FBANKBRANCH']}',
		FIFSCCODE = '{$rgPerArray['FIFSCCODE']}',
		FFAT_OCC = '{$rgPerArray['FFAT_OCC']}',
        FINCOME = '{$rgPerArray['FINCOME']}',
        FSEX = '{$rgPerArray['FSEX']}',
        FHANDICAP = '{$rgPerArray['FHANDICAP']}',
        FNATIONAL = '{$rgPerArray['FNATIONAL']}',
        FCOMBCODE = '{$rgPerArray['FCOMBCODE']}',
		FPREVCOMB = '{$rgPerArray['FPREVCOMB']}',
		FPREVMAX = '{$rgPerArray['FPREVMAX']}',
		FPREVSEC = '{$rgPerArray['FPREVSEC']}',
		FPREVPERCENT = '{$rgPerArray['FPREVPERCENT']}',
		FPREVREGNO = '{$rgPerArray['FPREVREGNO']}',
        FPREVCOLLEGE = '{$rgPerArray['FPREVCOLLEGE']}',
        FPASSMTHYEAR = '{$rgPerArray['FPASSMTHYEAR']}'
		where fappno = '{$fappno}'";
		// var_dump($query);		
	$result = mysqli_query($conn,$query);

	if($result && $result5)
	{	
		$row['status'] = 'success'; 
		$row['msg'] = 'Updated Successfully';
		echo json_encode($row);
	}
	else
	{
		$row['status'] = 'failure'; 
		$row['msg'] = 'Updation Failed';
		echo json_encode($row);
	}	

?>