MMCT TEAM
Server IP : 162.214.80.37  /  Your IP : 216.73.216.83
Web Server : Apache
System : Linux sh013.webhostingservices.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : imyrqtmy ( 2189)
PHP Version : 8.2.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home2/imyrqtmy/public_html/builty/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/imyrqtmy/public_html/builty/admin/add_client.php
<?php

include("inc/config.php");

if(isset($_POST['add_client'])){
    $client_name = $_POST['client_name'];
    $phone = $_POST['phone'];
    $email = $_POST['email'];
    $client_gst = $_POST['client_gst'];
    $destination = $_POST['destination'];
    $client_eway = $_POST['client_eway'];
    $client_address = $_POST['client_address'];

    
    	

 
    $client_name = mysqli_real_escape_string($conn, $client_name);
    $phone = mysqli_real_escape_string($conn, $phone);
    $email = mysqli_real_escape_string($conn, $email);
    $client_gst = mysqli_real_escape_string($conn, $client_gst);
    $destination = mysqli_real_escape_string($conn, $destination);
    $client_eway = mysqli_real_escape_string($conn, $client_eway);
    $client_address	 = mysqli_real_escape_string($conn, $client_address	);



    // Construct the SQL query with sanitized input data

    $query = "INSERT INTO `clients` (`client_name`, `phone`, `email`, `client_gst`,  `destination`,`client_eway`,`client_address` ) VALUES ('$client_name', '$phone','$email', '$client_gst','$destination', '$client_eway', '$client_address')";

   
    $query_run = mysqli_query($conn, $query);

    if($query_run){
     
        $_SESSION['status'] = "Data Uploaded Successfully";
        header('Location: view-client.php');
        exit;
    } else {
        $_SESSION['status'] = "Data Not Uploaded Successfully";
        header('Location: client.php');
        exit;
    }
}


if (isset($_POST['update_client'])) {
    $id = $_POST['id'];
    $client_name = $_POST['client_name'];
    $phone = $_POST['phone'];
    $email = $_POST['email'];
    $client_gst = $_POST['client_gst'];
    $destination = $_POST['destination'];
    
    $client_eway = $_POST['client_eway'];
    $client_address = $_POST['client_address'];

    // Update the project information in the database
    $query = "UPDATE clients 
              SET client_name='$client_name',
                phone='$phone',
                email='$email',
                client_gst='$client_gst',
                 destination='$destination',

                client_eway='$client_eway',
                client_address='$client_address'

                WHERE id='$id'";

    $query_run = mysqli_query($conn, $query);

    if ($query_run) {
        $_SESSION['status'] = "client Updated Successfully";
        header('Location: view-client.php');
    } else {
        $_SESSION['status'] = "client Not Updated Successfully";
        header('Location: view-client.php');
    }
}







// delete

if (isset($_POST['delete_client'])) {
    $id = $_POST['delete_id'];

    $query = "DELETE FROM clients WHERE id = '$id'";
    $query_run = mysqli_query($conn, $query);

    if ($query_run) {
        $_SESSION['status'] = "Deleted Successfully";
        header('Location: view-client.php');
    } else {
        $_SESSION['status'] = "Not Deleted Successfully";
        header('Location: view-client.php');
    }
}

?>

MMCT - 2023