<?php
$errmsg='';
$sucmsg='';
if(isset($_POST['update'])){
    extract($_POST);
    $errmsg='';
    $sucmsg='';
    
		//update record
        //$employer = mysql_real_escape_string($employer);
        $employer = str_replace("'", "", $employer);
        //$address = mysql_real_escape_string($address); 
         $address = str_replace("'", "", $address);
        //$nature = mysql_real_escape_string($nature);
         $nature = str_replace("'", "", $nature);
        //$position = mysql_real_escape_string($position);
         $position = str_replace("'", "", $position);

	$qry2=mysqli_query($con, "UPDATE pci_employer SET employer='$employer', address='$address', nature='$nature', position='$position', employmentDate='$employmentDate' where applicant_id='$applicant_idpci'");
	if($qry2){
		$sucmsg='Successful!';
	}else{
		$errmsg='Not Successful!';
	}
	
    
}



//GET DETAILS FROM DB
	
	$q = "Select * from pci_employer where applicant_id='$applicant_idpci'";
    $qry=mysqli_query($con, $q);
	if($qry){
		
		if(mysqli_num_rows($qry) >0){
			$row=mysqli_fetch_assoc($qry);
			extract($row);
			
		}else{ $errmsg='details not found!'; }
				
	}else{
		$errmsg='details not found!';
	}
?>

<div class="graph-visual tables-main">
<h2 class="inner-tittle">EMPLOYER’S DETAILS</h2>
	<div class="graph-form">
    		<div class="form-body">
    			<form method="post" name="employerform" action="index.php?page=employer"> 
                <?php 
                if($errmsg!=''){
                    echo '<div class="alert alert-danger">'.$errmsg.'</div>';
                }elseif($sucmsg!=''){
                    echo '<div class="alert alert-success">'.$sucmsg.'</div>';
                }
                
                ?>
                    <div class="form-group"> 
                        <label>Employer Name</label> 
                        <input type="text" class="form-control" name="employer" value="<?php echo $employer; ?>" required="" />  
                    </div> 
                    
					<div class="form-group"> 
                        <label>Employer's Address</label> 
                        <input type="text" class="form-control" name="address" value="<?php echo $address; ?>" required="" /> 
                    </div> 
                    
					<div class="form-group"> 
                        <label>Nature of Business</label> 
                        <input type="text" class="form-control" name="nature" value="<?php echo $nature; ?>" required="" /> 
                    </div> 
					
					<div class="form-group"> 
                        <label>Position</label> 
                        <input type="text" class="form-control" name="position" value="<?php echo $position; ?>" required="" />  
                    </div> 
                    
					<div class="form-group"> 
                        <label>Date Employed</label> 
                        <input type="date" class="form-control" name="employmentDate" value="<?php echo $employmentDate; ?>" required="" />  
                    </div> 
                    
			<div class="form-group"> 		
                    <input name="update" type="submit" class="btn btn-default" value="Update Details"/> 
                </form> 
    		</div>
    
    </div>

</div>

<div>
<a href='?page=experience'><button class='btn'>Back</button></a>

<?php
if(strlen($employer)>0){
 echo " <a href='?page=sponsor'><button class='btn'>Next</button></a> ";
}
?>

</div>