CasperSecurity
<?php
session_start();
include'../../../../../connection/connection.php';
$connection = new createConnection();
$connection->connect();
//$hostel_id = $_REQUEST['hostel_id'];
//$floor_id = $_REQUEST['floor_id'];
$hostel_name = $_REQUEST['hostel_name'];
$floor = $_REQUEST['floor'];
$room_no = $_REQUEST['room_no'];
$occupancy = $_REQUEST['occupancy'];
$date = date('Y-m-d');
$userId = $_SESSION['userId'];
$is_active = 'yes';
$select ="SELECT * FROM class WHERE host_room_no = '$room_no' AND is_active = 'yes'";
$query = mysqli_query($connection->myconn, $select);
$num=mysqli_num_rows($query);
if($num >= 1)
{
$_SESSION['ERROR_MSG'] = "Room No Already Exist";
$_SESSION['MSG_ALRT'] = "FALSE";
header('location:Hostel_Room.php');
}
else{
$newInsert ="INSERT INTO hostel_room(host_room_no,occupancy,created_on,created_by,is_active)
VALUES('$room_no','$occupancy','$date','".(int)$userId."','$is_active')";
if(mysqli_query($connection->myconn,$newInsert) === TRUE ){
$_SESSION['ERROR_MSG'] = "Data Inserted Successfully";
$_SESSION['MSG_ALRT'] = "TRUE";
//header('location:../../../../web/home/modules/university/Library/itemtype/item_type.php');
header('location:Hostel_Room.php');
} else {
$_SESSION['ERROR_MSG'] = "Unsuccess";
$_SESSION['MSG_ALRT'] = "FALSE";
//header('location:../../../../web/home/modules/university/Library/itemtype/item_type.php');
header('location:Hostel_Room.php');
}
}
?>