<?php session_start();
   require_once("../config/config.php");
   //require_once("../config/commonsetting.php");
   
   $myformId=SESS_MASTER;
   $myIp= ipCheck() ;
   $dateceated=date("Y-m-d H: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.'phone']);
   $emailid	=   secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'emailid']);
   $userpass		=   secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'userpass']);
   $comp_add		=   secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'company_address']);
   $web_add		=   secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'website_name']);
   $country		=   secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'country']);
   $userids		=   secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'userid']);
  
   /*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_vendor'];
   $hash = md5($userpass,PASSWORD_DEFAULT);
   
    if($_POST){
     try{
   		$olgaquery="UPDATE vendor_master SET createdIp='$myIp',datecreated='$dateceated',createdby='$createdby', full_name='$full_name', company_name='$company_name', mobileno='$mobileno', emailid='$emailid',location_country='$country', comp_add='$comp_add', web_add='$web_add', phone='$phone'"; 
   		
   		if (!empty($_FILES[SESS_MASTER.'file_up']['name'])){
   		         	$olgaquery= $olgaquery.",profile_pic='$add' WHERE rowId='$userids'";
   		}else{
   		    	$olgaquery= $olgaquery." WHERE rowId='$userids'";
   		}
   		$stmt = $conn->prepare($olgaquery);
   		if($stmt->execute()){
   			$last_insert_id = $conn->lastInsertId();
   
   			$_SESSION["created"] = $last_insert_id ;
   			//echo "hhhhg";
   			 //echo "<script>window.location='../merchant-user/'.$userids;</script>";
                header('Location: ../merchant-user/'.$userids);
   		}
    
    
      }
            
           // show error
           catch(PDOException $exception){
               die('ERROR: ' . $exception->getMessage());
           }
       }
   
   
   ?>