<?php
	if(isset($_POST['btnActivateAccound'])){
		
		$email=$_POST['email'];
		$key=$_POST['key'];
		
		if(empty($email)){
			$activate_error='<div class="alert alert-info">
			 			<button class="close" data-dismiss="info" type="button">
			 				
    		 			</button>
						<img src="images/info.png" />Enter your Email
                    </div>';
		}elseif(empty($key)){
			$activate_error='<div class="alert alert-info">
			 			<button class="close" data-dismiss="info" type="button">
			 				
    		 			</button>
						<img src="images/info.png" />Enter your Activation Code
                    </div>';
		}else{
		
		$sqlcheck=mysqli_query($con, "SELECT * FROM users WHERE email = '$email' AND code='$key'");
			if($sqlcheck){
			 $sqlrow=mysqli_num_rows($sqlcheck);
			 if($sqlrow >0 ){
				$fid=mysqli_fetch_array($sqlcheck);
				$std_id=$fid['user_id'];
				$number=$fid['number'];
		
		
		
			 $pass=md5($key);
			 
			 $sqlupdate=mysqli_query($con, "UPDATE users SET status='1' WHERE user_id='$std_id' AND code !=''") or die(mysql_error());
			 
			 if($sqlupdate){
			 $activate_error='<div class="alert alert-info">
			 			<button class="close" data-dismiss="info" type="button">
			 				
    		 			</button>
						<img src="images/info.png" />Your account has been activated successfuly, you can now log in with your Matric Number And your Activation Code</font>
				 <font color="green"><a href="index.php">Click here to login</a></font>
                    </div>';
				
				 
				
				//destroy the jamb session
				 session_destroy();
			 }else{
			 $activate_error='<div class="alert alert-info">
			 			<button class="close" data-dismiss="info" type="button">
			 				
    		 			</button>
						<img src="images/info.png" />Activataion error, Please use a valid entry to activate<br/>
						Also NOTE that there is no more space for 200L And 300L
                    </div>';
				
			 }
			
			
			
		}else{
		
		 $activate_error='<div class="alert alert-info">
			 			<button class="close" data-dismiss="info" type="button">
			 				
    		 			</button>
						<img src="images/info.png" />Activataion error, Please use a valid Email and Activation Code sents to your mobile phone
                    </div>';
		}
		
		
	}
}	
		
		
	}
	
	
	
	?>