<?php
session_start();
if (!isset($_SESSION['username'])) {
    echo "<script>window.top.location.href='index.php';</script>"; // Redirect parent window to login page
    exit();
}


include 'connect.php';
if(isset($_POST['submit'])){
    $cust_name=$_POST['cust_name'];
    $cust_company=$_POST['cust_company'];
    $cust_mobile=$_POST['cust_mobile'];
    $cust_email=$_POST['cust_email'];
   
    

   
    $sql = "insert into customer_table (cust_name, cust_company, cust_mobile, cust_email) values ('$cust_name','$cust_company','$cust_mobile','$cust_email')";
    $result=mysqli_query($conn, $sql);
    if($result){
        //echo "Data inserted succesfully";
        header('location: display_customer.php');
    }else{
        die(mysqli_error($conn));
    }
}

?>

<!doctype html>
<html lang="en" dir="ltr">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- Bootstrap CSS -->
<!--<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.rtl.min.css">-->
<link rel="stylesheet" href="css/bootstrap.min.css">

    <title>CRUD APPLICATION</title>
  </head>
  <body>
    <div class="container my-5"> 

    <h3>Please fill all the textboxes to add a new customer to the system</h3>

        <form method="POST">
            <div class="mb-3">
                <label for="formGroupExampleInput" class="form-label">Fullname:</label>
                <input type="text" class="form-control" name="cust_name" autocomplete="off" placeholder="Enter your Customername">
            </div>
            <div class="mb-3">
                <label for="formGroupExampleInput" class="form-label">Company:</label>
                <input type="text" class="form-control" name="cust_company" autocomplete="off" placeholder="Enter Customer Company Name">
            </div>

            <div class="mb-3">
                <label for="formGroupExampleInput" class="form-label">Mobile:</label>
                <input type="text" class="form-control" name="cust_mobile" autocomplete="off" placeholder="Enter Customer mobile number">
            </div>
            
            <div class="mb-3">
                <label for="formGroupExampleInput2" class="form-label">Email:</label>
                <input type="email" class="form-control" name="cust_email" autocomplete="off" placeholder="Enter Customer email">
            </div>
            
          

            <button type="submit" class="btn btn-primary" name="submit">Submit</button>
        </form>    

    </div>

    <script src="js/jquery.min.js"></script>
<script src="js/bootstrap.bundle.min.js"></script>
  </body>
</html>