29 lines
901 B
PHP
29 lines
901 B
PHP
<?php
|
|
require_once 'db/config.php';
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$client_id = $_POST['client_id'] ?? null;
|
|
$name = $_POST['name'] ?? null;
|
|
$email = $_POST['email'] ?? null;
|
|
$phone = $_POST['phone'] ?? null;
|
|
$role = $_POST['role'] ?? null;
|
|
|
|
if ($client_id && $name && $email) {
|
|
try {
|
|
$pdo = db();
|
|
$sql = "INSERT INTO contacts (client_id, name, email, phone, role) VALUES (?, ?, ?, ?, ?)";
|
|
$stmt = $pdo->prepare($sql);
|
|
$stmt->execute([$client_id, $name, $email, $phone, $role]);
|
|
|
|
header("Location: contacts.php?success=1");
|
|
exit();
|
|
} catch (PDOException $e) {
|
|
header("Location: contacts.php?error=" . urlencode($e->getMessage()));
|
|
exit();
|
|
}
|
|
} else {
|
|
header("Location: contacts.php?error=invalid_input");
|
|
exit();
|
|
}
|
|
}
|
|
?>
|