<?php
//update 
			if(isset($_POST["disability"]))
			{
			   //updated profile
			   extract ($_POST);
			   //print_r($_POST);

			   $q2 = "update prob_application set disability='$disability', disability_type='$disability_type' where id=$applicant_idgdef limit 1";
			   $r2 = mysqli_query($con, $q2);
			   
			   if(!$r2){
				   //echo mysqli_error($con); 
				   $errmsg = "Disability Status was not updated, please fill the form correctly";
				 } else {
				   $sucmsg = "Disability Status updated successfully"; 
			    }
			   
			}
                
?>

<div class="graph-visual tables-main">
<h2 class="inner-tittle">DISABILITY</h2> 
	<div class="graph-form">
    		<div class="form-body">
    			<form method="post" name="disabilityform" action="index.php?page=disability&i=<?php echo $_GET['i']; ?>"> 
                <?php 
                if($errmsg!=''){
                    echo '<div class="alert alert-danger">'.$errmsg.'</div>';
                }elseif($sucmsg!=''){
                    echo '<div class="alert alert-success">'.$sucmsg.'</div>';
                }
                

				
                   //GET DETAILS FROM DB

		    $q = "Select * from prob_application where id='$applicant_idgdef' limit 1";
			//echo $q;
		    $qry=mysqli_query($con, $q);
		    $row=mysqli_fetch_assoc($qry);
		    extract($row);
		    
		    if(!empty($disability_type)){ $dis_available = "Yes"; $mydisability=$disability_type; }else{ $dis_available = "No"; }
         
                
                ?>	
                	<label>Do you have any disability? </label>
                   	 <select name="disability" class="form-control" style="height:auto" required="required">
                   		<option value="">-select option-</option>
			  			<option <?php if($disability == "YES"){ echo "selected"; } ?>>YES</option>
			  			<option <?php if($disability == "NO"){ echo "selected"; } ?>>NO</option>
			  		
			  </select>
			  <br />

					<label>If your answer above is YES, kindly specify the disability </label>
                   	<input type="text" name="disability_type" <?php if(!empty($mydisability)){ echo " value='".$mydisability."'"; } ?> class="form-control" />
			
                    <input name="updateDisability" type="submit" class="btn btn-default" value="Update Disability Status"/> 
                </form> 
			
			
		

    		</div>
    
    </div>

</div>
<div>

<?php
echo "<a href='?page=passport&i=".$_GET['i']."'><button class='btn'>Back</button></a>";

//check disability

if(!empty($disability) && $disability == "YES" && !empty($disability_type))
{
  	echo "<a href='?page=education&i=".$_GET['i']."'><button class='btn'>Next</button></a>";
}elseif(strlen($disability)>0 && $disability == "NO"){
	echo "<a href='?page=education&i=".$_GET['i']."'><button class='btn'>Next</button></a>";
} 

?>
</div>


