<?php
include('../../db_connect/db.php');

//get datas from the form
$title = $_POST['title'];
$description = $_POST['description'];
$date = $_POST['date'];
$by_name=$_POST['by_name'];
$user_status=$_POST['user_status'];
$status=$_POST['status'];

//check to see if record already exit
$check = mysqli_query($conn_1, "SELECT *FROM hostel_campuses WHERE title='$title' ") or die(mysqli_error($conn_1));
if($check){
  $sql_verify_title_row=mysqli_num_rows($check);
						if($sql_verify_title_row > 0){
							$status='This Hostel Site already exist, thank you.';
      }else{
            //insert into the database
            $insert= mysqli_query($conn_1, "INSERT INTO hostel_campuses(title,description,published,date_added,added_by,status)
             VALUES('$title','$description','$status',NOW(),'$by_name','$user_status')");
             if($insert){
               $status='Successfully added.';
             }else{
               $status='Something went wrong, contact developer.';
             }
          }
}
echo $status;
?>
