<?php
    require_once('include/config.php');
    require_once('include/startup.php');                           
    $alltables = new AllTables();

    if ($_POST['btn-submit']) 
    {
      
            $company_name               = $_POST['txt_cmpname'];
            $company_type               = $_POST['txt_cmptype'];
            $hall_no                    = $_POST['txt_hallno'];
            $stall_no                   = $_POST['txt_stallno'];
            
            $address                    = $_POST['txt_address'];
            $country                    = $_POST['txt_country'];
            $State                      = $_POST['txt_state'];
            $city                       = $_POST['txt_city'];
            $pincode                    = $_POST['txt_pincode'];
            
            $company_email              = $_POST['txt_cmpemail'];
            $phone_no                   = $_POST['txt_phone'];
            $whatsapp_no                = $_POST['txt_whatsapp'];
            $website                    = $_POST['txt_website'];
            
            $gst_no                     = $_POST['txt_cmpgst'];
            $pan_no                     = $_POST['txt_cmppan'];
            $tan_no                     = $_POST['txt_cmptan'];
            $cin_no                     = $_POST['txt_cmpcin'];
            
        
        
            $array['cmp_name']          = $company_name;     
            $array['cmp_type']          = $company_type;
            $array['hall_no']           = $hall_no;
            $array['stall_no']          = $stall_no;
            
            $array['address']           = $address;
            $array['country']           = $country;       
            $array['state']             = $State;
            $array['city']              = $city;
            $array['pincode']           = $pincode;
            
            $array['cmp_email']         = $company_email;
            $array['phone']             = $phone_no;            
            $array['whatsapp']          = $whatsapp_no;
            $array['cmp_website']       = $website;
            
            $array['cmp_gst']           = $gst_no;
            $array['cmp_pan']           = $pan_no;
            $array['cmp_tan']           = $tan_no;
            $array['cmp_cin']           = $cin_no;
                                
            
            $last_cmpid = $alltables -> AddInfo($array,'mst_company'); 
            // echo "Last insetr id:".$last_cmpid;
            // exit();   
            
            if($last_cmpid){
                $user_name                      = $_POST['txt_user'];
                $password                       = $_POST['txt_password'];
                
                $login_array['cmp_id']              = $last_cmpid;
                $login_array['username']            = $user_name;       
                $login_array['password']            = $password;
                
                $login_info = $alltables -> AddInfo($login_array,'mst_user'); 
                
                
                echo '<script>alert("Form submitted successfully!");window.location.href = "login.php";</script>';
                exit();
            }
            else{
                echo '<script>alert("Form not submitted, please try again. ");window.location.href = "user-registration.php";</script>';
                exit();
            }
    }  
    else{
                                
    }
       
    include_once('user-registration1-demo.html');           
?>    