<?php
include("../includes/db_connection.php");
include("../includes/auth.php");

$id = $_POST['id'];
$name = $_POST['name'];
$associate_id = $_POST['associate_id'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$city = $_POST['city'];
$country = $_POST['country'];
$address = $_POST['address'];

if($id){

$stmt = $conn->prepare("UPDATE clients SET 
associate_id=?,name=?,email=?,phone=?,city=?,country=?,address=?
WHERE id=?");

$stmt->bind_param("issssssi",
$associate_id,$name,$email,$phone,$city,$country,$address,$id);

} else {

$stmt = $conn->prepare("INSERT INTO clients
(associate_id,name,email,phone,city,country,address)
VALUES (?,?,?,?,?,?,?)");

$stmt->bind_param("issssss",
$associate_id,$name,$email,$phone,$city,$country,$address);
}

$stmt->execute();

header("Location: clients.php");
exit;
?>