<?php include("db.php"); ?>
                <h3>Register Courses</h3>
				
                <hr/>
                <div class="container">
					<div class="row">
						<div class="col-md-12" style="margin-left:-10px">
							<form action="index.php?env=semester-courses" method="POST" >
					   
							   <div class="form-group">
								   <h5 style="text-align:center;margin-bottom:40px;">Please Fill in Capital Letters</h5>
									<div class=" row form-group">
										<div class="col-md-6">
											<label for="name"> First name</label>
											<input type="text" name="fname" class="form-control" required>
										</div>
										<div class="col-md-6">
											<label for="name">Surname</label>
											<input type="text" name="sname" class="form-control" required>    
										</div>
									</div>
									
									<div class=" row form-group">
										<div class="col-md-6">
                                            <label for="name">Session</label>
                                            <select name="sessiond" id="" class="form-control" required>
                                                <option value="Select session">Select session</option>
                                                <option value="2022/2023">2022/2023</option>
                                                <option value="2023/2024">2023/2024</option>
                                            </select>    
										</div>
										<div class="col-md-6">
                                            <label for="name"> Program type</label>
											<select name="program" id="" class="form-control" required>
												<option value="Select program type">Select program type</option>
												<option value="ND Full TIme">ND Full Time</option>
												<option value="ND Part Time">ND Part Time</option>	
											</select>
										</div>
									</div>			
									<button type="submit" name="btnsubmit" class="btn-block btn-success" >Next</button>
								</div>
							</form>
						</div>
					</div>
				</div>
					

                    <div class="row" style="margin-top:50px;">
                        <div class="col-md-6">
                            <a href="index.php?env=courses" style="color:#ffffff;text-decoration:none;"> 
                                <button type="button" class="btn btn-primary btn-block"><i class="fa fa-arrow-left"></i> Go back</button>
                            </a>
                        </div>
                        <div class="col-md-6">
                        
                        </div>
                    </div>
<?php
	if(isset($_POST['btnsubmit'])){

		$fname = mysqli_real_escape_string($db, $_POST['fname']); 
		$sname = mysqli_real_escape_string($db, $_POST['sname']); 
		$sessiond = mysqli_real_escape_string($db,$_POST['sessiond']);
		$program = mysqli_real_escape_string($db,$_POST['program']);
		// $Dept = mysqli_real_escape_string($db,$_POST['Dept']);
		// $leveld = mysqli_real_escape_string($db,$_POST['leveld']);

		$query = "INSERT INTO registered_courses (fname, sname, sessiond, program) VALUES('$fname', '$sname', '$sessiond', '$program')";
		
		$query_result = mysqli_query($db, $query);

		if($query_result){
			header("location:index.php?env=semester-courses");
		}else{
			echo "not successful";
		}
	}

?>