File "reply-ticket-vendor.php"

Full Path: /home/u165092617/domains/tadzz.com/public_html/forms/reply-ticket-vendor.php
File size: 2.66 KB
MIME-type: text/x-php
Charset: utf-8

<?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';
   
   $user_id		=   secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'user_id']);
   $message	=   secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'message']);
   $ti_id	=   secureSuperGlobalPOST($_REQUEST[SESS_MASTER.'ti_id']);
   
    if($_FILES[SESS_MASTER.'myfile']['name']!=''){
        print_r($_FILES[SESS_MASTER.'myfile']);
         $errors= array();
         $file_name = $_FILES[SESS_MASTER.'myfile']['name'];
         $file_size =$_FILES[SESS_MASTER.'myfile']['size'];
         $file_tmp =$_FILES[SESS_MASTER.'myfile']['tmp_name'];
         $file_type=$_FILES[SESS_MASTER.'myfile']['type'];
         $file_ext=strtolower(end(explode('.',$_FILES[SESS_MASTER.'myfile']['name'])));
         
         $extensions= array("jpeg","jpg","png");
         
         if(in_array($file_ext,$extensions)=== false){
            $errors[]="extension not allowed, please choose a JPEG or PNG file.";
         }
         
         if($file_size > 2097152){
            $errors[]='File size must be excately 2 MB';
         }
         
         if(empty($errors)==true){
            move_uploaded_file($file_tmp,"upload/".$file_name);
            $pro="upload/".$file_name;
            echo "Success";
         }else{
            print_r($errors);
         }
      }
   
   
   
    if($_POST){
     try{
         echo $ti_id;
          $sql_ma = "SELECT * FROM ticket_master WHERE rowId='$ti_id'";
          
   	 $myquery_ma=$conn->query($sql_ma); 
   	$mydara_ma= $myquery_ma->fetchAll()  ;
   	$rows_found_ma = $myquery_ma->rowCount();
   			 foreach( $mydara_ma as $row_ma ) {
   				$active	= $row_ma['activestatus'];
   				
   			}
   			 
   	if($active=='0'){
   
   			$olgaquerys="INSERT INTO ticket_message SET createdIp='$myIp',datecreated='$dateceated',createdby='$createdby',ticket_id='$ti_id', message='$message',user_id='$user_id',user_type='1',activestatus='0'"; 
   			if (!empty($_FILES[SESS_MASTER.'myfile']['name'])){
   		         	$olgaquerys= $olgaquerys.",message_file='$pro'";
   		}
   		$stmts = $conn->prepare($olgaquerys);
   		if($stmts->execute()){
   
   			$_SESSION["ticket"] = $last_insert_id ;
   			
   			 header("location:../vendor-id/5");
   
   			}
   		
   	}
   		if($active=='1'){
   		    $_SESSION["ticket_failed"] = 'fail' ;
   		    header("location:../vendor-id/5");
   		}
    
      }
            
           // show error
           catch(PDOException $exception){
               die('ERROR: ' . $exception->getMessage());
           }
       }
   
   
   ?>