<?php session_start();
include("connect.php");

if(isset($_POST['see_matric_no'])){
	$bay=mysqli_query($con,"select * from student where matric_no='".trim($_POST['see_matric_no'])."'");	
	$row=mysqli_fetch_assoc($bay);
	if(mysqli_num_rows($bay)>0){			
	if(mysqli_num_rows($bay)>0 && $row['password']==''){
			$bxm=mysqli_query($con,"select * from `department` where id='".$row['dept_id']."'");	
			$sxm=mysqli_fetch_assoc($bxm);		
			$bam=mysqli_query($con,"select * from `faculty` where id='".$sxm['fac_id']."'");	
			$sim=mysqli_fetch_assoc($bam);		
			$kap=mysqli_query($con,"select * from programme where id='".$row['programme_id']."'");    
			$dos=mysqli_fetch_assoc($kap);
			
			
				  echo '<input type="hidden" value="'.$row['id'].'" name="studentid" required>				  				  <div class="row">
						<div class="form-group col-md-6">
						<label class="control-label mb-5" for="email_de">Surname</label>
						<input type="text" style="height:46px; border-radius:0;" value="'.$row['sname'].'" class="form-control" required readonly>
						</div>
						
						<div class="form-group col-md-6">
						<label class="control-label mb-5" for="email_de">Othernames</label>
						<input type="text" style="height:46px; border-radius:0;" value="'.ucwords(strtolower($row['fname'].' '.$row['mname'])).'" class="form-control" required readonly>
						</div>
						
						<div class="form-group col-md-4">
						<label class="control-label mb-5" for="email_de">Year of Entry</label>
						<input type="text" style="height:46px; border-radius:0;" value="'.$row['entry'].'" class="form-control" required readonly>
						</div>
						
						<div class="form-group col-md-4">
						<label class="control-label mb-5" for="email_de"> Campus</label>
						<select style="height:46px; border-radius:0;" name="student_campus" class="form-control" required>
						<option value="">Select</option>';
							echo '<option value="'.$row['campus'].'">'.ucwords($row['campus']).'</option>';
						echo '</select>
						</div>
						
						
						<div class="form-group col-md-4">
						<label class="control-label mb-5" for="email_de">Faculty</label>
						<input type="text" style="height:46px; border-radius:0;" value="'.ucwords(strtolower($sim['faculty'])).'" class="form-control" required readonly>
						</div>
						
						<div class="form-group col-md-6">
						<label class="control-label mb-5" for="email_de">Department</label>
						<input type="text" style="height:46px; border-radius:0;" value="'.$sxm['department'].'" class="form-control" required readonly>
						</div>
						
						<div class="form-group col-md-6">
						<label class="control-label mb-5" for="email_de">Programme</label>
						<select style="height:46px; border-radius:0;" name="student_programme" class="form-control" required>
						<option value="">Select</option>';
							echo '<option value="'.$dos['id'].'">'.$dos['name'].' ('.$dos['description'].')</option>';
						echo '</select>
						</div>
						
						<div class="form-group col-md-12">
						<label class="control-label mb-5" for="email_de">Email</label>
						<input type="email" name="student_email" style="height:46px; border-radius:0;" class="form-control" required>
						</div>
						
						
						</div>
						
						<div class="row">
						<div class="form-group col-md-6">
						<label class="control-label mb-5" for="email_de">Password</label>
						<input type="password" placeholder="Choose Password" style="height:46px; border-radius:0;" class="form-control" name="password" required >
						</div>
						
						<div class="form-group col-md-6">
						<label class="control-label mb-5" for="email_de">Confirm Password</label>
						<input type="password" placeholder="Re-Type Password" style="height:46px; border-radius:0;" class="form-control" name="cpassword" required >
						</div>
						</div>
			
			<div class="checkbox checkbox-primary" align="center">
						
						<label for="checkbox2" style="font-size:13px;"><input id="checkbox2" type="checkbox" style="margin-top:;" required> Click to indicate that you are not creating this account on behalve of someone else</label>
						</div>
						
						 <button class="view-cart-btn btn pull-right" type="submit">Create Account </button>
							 <div class="clearfix"></div>';
	}else{
			  
		echo '<div class="alert alert-dismissible alert-danger">
				<strong>SORRY: </strong> Student already registered.
              </div>';	  
	}}else{
			  
		echo '<div class="alert alert-dismissible alert-danger">
				<strong>SORRY: </strong> Incorrect Student Matric No or Student is yet to be pre-enrolled. kindly visit the Admin if you think otherwise.
              </div>';	  
	}
}


?>