<?php
function throw_ex($er)
{
throw new Exception($er);
}
if(isset($_POST['btn_add']))
{
$stud_id = $_POST['stud_id'];
$stud_lrn = $_POST['stud_lrn'];
$stud_lname = $_POST['stud_lname'];
$stud_fname = $_POST['stud_fname'];
$stud_mname = $_POST['stud_mname'];
$stud_contact = $_POST['stud_contact'];
$stud_address = $_POST['stud_address'];
$stud_barangay = $_POST['stud_barangay'];
$stud_municipality = $_POST['stud_municipality'];
$stud_province = $_POST['stud_province'];
$stud_bday = $_POST['stud_bday'];
$stud_bplace = $_POST['stud_bplace'];
$stud_mother_name = $_POST['stud_mother_name'];
$stud_mother_bday = $_POST['stud_mother_bday'];
$stud_mother_occupation = $_POST['stud_mother_occupation'];
$stud_mother_contact = $_POST['stud_mother_contact'];
$stud_father_name = $_POST['stud_father_name'];
$stud_father_bday = $_POST['stud_father_bday'];
$stud_father_occupation = $_POST['stud_father_occupation'];
$stud_father_contact = $_POST['stud_father_contact'];
$check = mysqli_query($con,"SELECT * from tbl_studentprofile where stud_lname ='".$stud_lname."' and stud_mname = '".$stud_mname."' and stud_fname = '".$stud_fname."'");
$ct = mysqli_num_rows($check);
if($ct == 0)
{
$query = "INSERT INTO tbl_studentprofile(stud_id, stud_lrn, stud_lname, stud_fname, stud_mname, stud_contact, stud_address, stud_barangay,stud_municipality, stud_province, stud_bday, stud_bplace,stud_mother_name, stud_mother_bday,stud_mother_occupation,stud_mother_contact,stud_father_name,stud_father_bday,stud_father_occupation,stud_father_contact,)VALUES ('".$stud_id."','".$stud_lrn."','".$stud_lname."','".$stud_fname."','".$stud_mname."','".$stud_contact."','".$stud_address."','".$stud_barangay."','".$stud_municipality."','".$stud_province."','".$stud_bday."','".$stud_bplace."','".$stud_mother_name."','".$stud_mother_bday."','".$stud_mother_occupation."','".$stud_mother_contact."','".$stud_father_name."','".$stud_father_bday."','".$stud_father_occupation."','".$stud_father_contact."')";
$run = mysqli_query($con,$query);
if(!$query)
{
throw_ex(mysqli_error());
}else
{
echo '<script>alert("Passed query");</script>';
}
}else
{
echo "Duplicate";
}
}
?>
`