<?php
include_once('../../../db_connect/db.php');
	$school_id=mysqli_real_escape_string($con,$_POST["school_id"]);
	$title=mysqli_real_escape_string($con,$_POST["title"]);
	$description=mysqli_real_escape_string($con,$_POST["description"]);
	$added_by=mysqli_real_escape_string($con,$_POST["added_by"]);
	$status=mysqli_real_escape_string($con,$_POST["status"]);


	$check = mysqli_query($con, "SELECT *FROM hostel_sites WHERE title = '$title' ") or die(mysqli_error($dbc));
	if($check){
	  $sql_verify_title_row=mysqli_num_rows($check);
							if($sql_verify_title_row > 0){
								$status='This Campus already exist, thank you.';
	      }else{
	            //insert into the database
	            $insert= mysqli_query($con, "INSERT INTO hostel_sites(school_id,title,description,added_by,status)
	             VALUES('$school_id','$title','$description','$added_by','$status') ") or die(mysqli_error($con));
	             if($insert){
	               echo 1;
	             }else{
								 echo $error='<div class="alert alert-success alert-dismissible" role="alert">
						 			 <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
						 			 <strong>Alert!</strong> Campus not saved sucessfully.
						 			</div>';
	             }
	          }
	}



?>
