<?php
include 'include/db.php';

//  check details already inserted or not
$qry="select * from company_details";
$con=mysqli_query($conn,$qry);
if(mysqli_num_rows($con)>0)
{
     echo '<script> alert("Details already added into database "); window.location="company_details_edit.php"; </script>';
     exit;
}
// if not inserted then insert new value
date_default_timezone_set("Asia/Kolkata");
$company_name=mysqli_real_escape_string($conn,$_REQUEST['company_name']);
$business_name=mysqli_real_escape_string($conn,$_REQUEST['business_name']);
$website_link=mysqli_real_escape_string($conn,$_REQUEST['website_link']);
$gst_number=mysqli_real_escape_string($conn,$_REQUEST['gst_number']);
$reg_number=mysqli_real_escape_string($conn,$_REQUEST['reg_number']);
$company_email=mysqli_real_escape_string($conn,$_REQUEST['company_email']);
$company_phone=mysqli_real_escape_string($conn,$_REQUEST['company_phone']);
$company_addrress=mysqli_real_escape_string($conn,$_REQUEST['company_addrress']);
$prefix=mysqli_real_escape_string($conn,$_REQUEST['prefix']);
$default_admin_id=mysqli_real_escape_string($conn,$_REQUEST['default_admin_id']);
$date=date('Y-m-d H:i');

$query="insert into company_details(default_admin_id,company_name,business_name,website_link,gst_number,registration_number,company_email,company_phone,company_address,details_crt_date,details_mdf_date)
        values('$default_admin_id','$company_name','$business_name','$website_link','$gst_number','$reg_number','$company_email','$company_phone','$company_addrress','$date','')";
$connection=mysqli_query($conn,$query);
if($connection)
{
    echo '<script> alert("Details submitted successfully"); window.location="company_details.php"; </script>';
}
else
{
     echo '<script> alert("sorry, something went wrong"); window.location="company_details.php"; </script>';
}
?>