35429-vm/add_client.php
2025-11-02 20:12:50 +00:00

27 lines
765 B
PHP

<?php
require_once 'db/config.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = $_POST['name'] ?? null;
$website = $_POST['website'] ?? null;
$status = $_POST['status'] ?? 'Active';
if ($name) {
try {
$pdo = db();
$sql = "INSERT INTO clients (name, website, status) VALUES (?, ?, ?)";
$stmt = $pdo->prepare($sql);
$stmt->execute([$name, $website, $status]);
header("Location: clients.php?success=1");
exit();
} catch (PDOException $e) {
header("Location: clients.php?error=" . urlencode($e->getMessage()));
exit();
}
} else {
header("Location: clients.php?error=invalid_input");
exit();
}
}
?>