CasperSecurity
<?php
session_start();
include'../../../../../connection/connection.php';
$connection = new createConnection();
$connection->connect();
$subject_code = $_REQUEST['subject_code'];
$subject_name = $_REQUEST['subject_name'];
$syllabusid = $_REQUEST['syllabusid'];
$syllabus_year = $_REQUEST['syllabus_year'];
$date = date("Y-m-d");
$userId = $_SESSION['userId'];
$is_active = 'yes';
$select ="SELECT * FROM hostel WHERE subject_name = '$subject_name' AND is_active = 'yes'";
$query = mysqli_query($connection->myconn, $select);
$num=mysqli_num_rows($query);
if($num >= 1)
{
$_SESSION['ERROR_MSG'] = "Subject Already Exits";
$_SESSION['MSG_ALRT'] = "FALSE";
header('location:subject.php');
}
else{
$newInsert ="INSERT INTO subject(subject_code,subject_name,syllabusid,syllabus_year,created_on,created_by,is_active)
VALUES('$subject_code','$subject_name','$syllabusid','$syllabus_year','$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:subject.php');
} else {
$_SESSION['ERROR_MSG'] = "Unsuccess";
$_SESSION['MSG_ALRT'] = "FALSE";
//header('location:../../../../web/home/modules/university/Library/itemtype/item_type.php');
header('location:subject.php');
}
}
?>