<?php
$errmsg='';
$sucmsg='';
if(isset($_POST['update'])){
    extract($_POST);
    $errmsg='';
    $sucmsg='';
    
		//update record
	$qry2=mysqli_query($con, "UPDATE pci_chapter SET memberNo='$memberNo', fullName='$fullName', memberEmail='$memberEmail', memberPhone='$memberPhone', stateChapter='$stateChapter', designation='$designation' WHERE applicant_id=$applicant_idpci");
	if($qry2){
		$sucmsg='Successful!';
	}else{
		$errmsg='Not Successful!';
	}
	
    
}


//initialize data
$memberNo ="";
$fullName ="";
$memberEmail ="";
$memberPhone ="";
$designation ="";
$stateChapter ="";

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

<div class="graph-visual tables-main">
<h2 class="inner-tittle">STATE CHAPTER CHAIRMAN/SECRETARY</h2>
	<div class="graph-form">
    		<div class="form-body">
    			<form method="post" name="sponsorform" action="index.php?page=chapter"> 
                <?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>Membership Number</label> 
                        <input type="text" class="form-control" name="memberNumber" value="<?php echo $memberNo; ?>" required="" />  
                    </div> 
                    
					<div class="form-group"> 
                        <label> Name</label> 
                        <input type="text" class="form-control" name="fullName" value="<?php echo strtoupper($fullName); ?>" required="" /> 
                    </div> 
                    
					<div class="form-group"> 
                        <label>Designation</label> 
                        <select class="form-control" style="height:auto" name="designation"> <option><?php echo strtoupper($designation); ?></option><option>CHAIRMAN</option><option>SECRETARY</option></select> 
                    </div> 
                    
					
					<div class="form-group"> 
                        <label>Email Address</label> 
                        <input type="text" class="form-control" name="memberEmail" value="<?php echo $memberEmail; ?>" required="" /> 
                    </div> 
                    
					<div class="form-group"> 
                        <label>Phone Number</label> 
                        <input type="text" class="form-control" name="memberPhone" value="<?php echo strtoupper($memberPhone); ?>" required="" /> 
                    </div> 
                    
					<div class="form-group"> 
                        <label>State</label> 
                        <input type="text" class="form-control" name="stateChapter" value="<?php echo strtoupper($stateChapter); ?>" required="" /> 
                    </div> 
                    
				
					
					
                    <input name="update" type="submit" class="btn btn-default" value="Update"/> 
                </form> 
    		</div>
    
    </div>

</div>