<?php session_start();
   require_once("../config/config.php");
   //require_once("../config/commonsetting.php");
   
   $myformId=SESS_MASTER;
   $myIp= ipCheck() ;
   $dateceated=date("Y-m-d G:i:s");
   $createdby='0';
   $full_name		=   secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'full_name']);
   $company_name		=   secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'company_name']);
   $mobileno	=   secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'mobileno']);
   $phone	=   secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'phone']);
   $emailid	=   secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'emailid']);
   $city		=   secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'city']);
   $state		=   secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'state']);
   $country		=   secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'country']);
   $dob		=   secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'dob']);
   $gender		=   secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'gender']);
   $website_name		=   secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'website_name']);
   $company_address =secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'company_address']);
   
   /*file upload*/
   if (!empty($_FILES[SESS_MASTER.'file_up']['name'])){
   $file_upload_flag="true";
   $file_up_size=$_FILES[SESS_MASTER.'file_up']['size'];
   if ($_FILES[SESS_MASTER.'file_up']['size']>2500000){
   $msg=$msg."Your uploaded file size is more than 2500KB ";
   $msg.=" so please reduce the file size and then upload.<BR>";
   $file_upload_flag="false";
   }
   
   // allow only jpeg or gif files, remove this if not required //
   if (!($_FILES[SESS_MASTER.'file_up']['type'] =="image/jpeg" OR $_FILES[SESS_MASTER.'file_up']['type'] =="image/png"))
   {$msg=$msg."Your uploaded file must be of JPG or GIF. ";
   $msg.="Other file types are not allowed<BR>";
   $file_upload_flag="false";}
   
   $file_name=$_FILES[SESS_MASTER.'file_up']['name'];
   // the path with the file name where the file will be stored
   $add="upload/".$file_name; 
   
   if($file_upload_flag=="true"){ // checking the Flag value 
   
   if(move_uploaded_file ($_FILES[SESS_MASTER.'file_up']['tmp_name'], $add)){
   // do your coding here to give a thanks message or any other thing.
   $msg="File successfully uploaded";
   }else{
   echo "Failed to upload file Contact Site admin to fix the problem";
   }
   }else{
   $msg .= " Failed to upload file ";
   }
   }
   //echo $msg;
   /*file upload*/
   
    $user_id=$_SESSION[ADD_TAG.'_UserId_user'];
   
   
    if($_POST){
     try{
   		$olgaquery="UPDATE user_master SET createdIp='$myIp',datecreated='$dateceated',createdby='$createdby', full_name='$full_name', company_name='$company_name', mobileno='$mobileno', emailid='$emailid',location_country='$country', location_state='$state', location_city='$city', phone='$phone', gender='$gender',website_name='$website_name',company_address='$company_address'"; 
   		
   		if (!empty($_FILES[SESS_MASTER.'file_up']['name'])){
   		         	$olgaquery= $olgaquery.",profile_pic='$add' WHERE rowId='$user_id'";
   		}else{
   		    	$olgaquery= $olgaquery." WHERE rowId='$user_id'";
   		}
   		$stmt = $conn->prepare($olgaquery);
   		if($stmt->execute()){
   			$last_insert_id = $conn->lastInsertId();
   
   			$_SESSION["created"] = $last_insert_id ;
   			 $_SESSION[ADD_TAG.'_Tab_id']='';
   			 echo "<script>window.location='../user-profile';</script>";;
   		}
    
    
      }
            
           // show error
           catch(PDOException $exception){
               die('ERROR: ' . $exception->getMessage());
           }
       }
   
   
   ?>