<!-- PHP script-->
<?php
//For database connection
include "includes/conn.php";
$msg="";
//for form submit
if(isset($_POST['submit'])){
	$first_name=mysqli_real_escape_string($con,$_POST['first_name']);
	$last_name=mysqli_real_escape_string($con,$_POST['last_name']);
	$age=mysqli_real_escape_string($con,$_POST['age']);
	//query to insert records intodatabase
	$insert=mysqli_query($con,"INSERT INTO `students`( `first_name`,`last_name`,`age`) VALUES ('$first_name','$last_name','$age')");
	if(mysqli_affected_rows($con)>0){
		//status message
		$msg="<div class='alert alert-success'>record added Successfully</div>";
	}
	else{
		$msg="<div class='alert alert-danger'>record not added Successfully</div>";
	}
}
?>
<!--html structure-->
<html>
  <head>
		<link rel="stylesheet" href="css/bootstrap.min.css">
		<link rel="stylesheet" type="text/css" href="css/style.css">
  </head>
  <body>
	<div class="content-wrap">
				<div class="main">
					<div class="container-fluid">
						<!-- /# row -->
						<div id="main-content" >
							<div class="row">
								<div class="col-sm-8 offset-2">
									
										<h1 class="">Add Student</h1>
									
									<div class="col-sm-12">
									<?php
									echo $msg;
									?>
									<!-- html form-->
										<form action="" method="post" role="form">
											<div class="form-group">
												<label>Enter First Name</label>
												<input type="text" class="form-control" name="first_name">
													
											</div>
											<div class="form-group">
												<label>Enter Last Name</label>
												<input type="text" class="form-control" name="last_name">
													
											</div>
											<div class="form-group">
												<label>Enter Age</label>
												<input type="number" class="form-control" name="age">
													
											</div>
											
											</div>
											<div class="form-group">
												<input type="submit"  class="btn btn-info" name="submit">
											</div>
										</form>
									</div>
								</div>
							</div>
			</div>
		</div>
	</div>

		<script src="js/bootstrap.min.js"></script>
	<body>
</html>