<?php
$errmsg='';
$sucmsg='';
if(isset($_POST['update'])){
    extract($_POST);
    $errmsg='';
    $sucmsg='';
    
		//update record
	$qry2=mysqli_query($con, "UPDATE tpcf_tpc SET tpcMonth='$tpcMonth', tpcYear='$tpcYear', tpcNo='$tpcNo', tpcCentre='$tpcCentre' where applicant_id='$applicant_id'");
	if($qry2){
		$sucmsg='Successful!';
	}else{
		$errmsg='Not Successful!';
	}
	
    
}



//GET DETAILS FROM DB
	
	$q = "Select * from tpcf_tpc where applicant_id='$applicant_id'";
    $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">PATICULARS OF TPC EXAMINATION  </h2>
	<div class="graph-form">
    		<div class="form-body">
    			<form method="post" name="tpcform" action="index.php?page=tpc"> 
                <?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>Month of Examination</label> 
                        <!--input type="text" class="form-control" name="tpcMonth" value="<?php echo $tpcMonth; ?>" required="" /-->  
                        <select class="form-control" name="tpcMonth" style="width:100%; height:auto">
                         <?php echo "<option>$tpcMonth</option>"; ?>
                         <option>JANUARY</option>
                         <option>FEBRUARY</option>
                         <option>MARCH</option>
                         <option>APRIL</option>
                         <option>MAY</option>
                         <option>JUNE</option>
                         <option>JULY</option>
                         <option>AUGUST</option>
                         <option>SEPTEMBER</option>
                         <option>OCTOBER</option>
                         <option>NOVEMBER</option>
                         <option>DECEMBER</option>
                         
                        </select>
                    </div> 
                    
					<div class="form-group"> 
                        <label>Year of Examination</label> 
                        <!--input type="text" class="form-control" name="tpcYear" value="<?php echo $tpcYear; ?>" required="" /--> 
                        <select class="form-control" name="tpcYear" style="width:100%; height:auto">
                         <?php echo "<option>$tpcYear</option>"; $y=date('Y'); for($iy=$y; $iy>1960; $iy--){ echo "<option>$iy</option>"; } ?>
                        </select>
                    </div> 
                    
					<div class="form-group"> 
                        <label>Examination Number</label> 
                        <input type="text" class="form-control" name="tpcNo" value="<?php echo $tpcNo; ?>" required="" /> 
                    </div> 
					
					<div class="form-group"> 
                        <label>Examination Centre</label> 
                        <input type="text" class="form-control" name="tpcCentre" value="<?php echo $tpcCentre; ?>" required="" /> 
                    </div> 
					
                    <input name="update" type="submit" class="btn btn-default" value="Update Details"/> 
                </form> 
    		</div>
    
    </div>

</div>

  
<div>
<a href='?page=body'><button class='btn'>Back</button></a>
<a href='?page=logbook'><button class='btn'>Next</button></a>
</div>

