prepare("UPDATE contacts SET name = :name, company = :company, email = :email, phone = :phone, source = :source, tags = :tags WHERE id = :id"); $stmt->execute([ ':name' => $name, ':company' => $company, ':email' => $email, ':phone' => $phone, ':source' => $source, ':tags' => $tags, ':id' => $id ]); header("Location: contacts.php?status=updated"); exit; } catch (PDOException $e) { $error = "Database error: " . $e->getMessage(); } } } try { $stmt = $pdo->prepare("SELECT * FROM contacts WHERE id = :id"); $stmt->execute([':id' => $id]); $contact = $stmt->fetch(); if (!$contact) { header("Location: contacts.php"); exit; } } catch (PDOException $e) { echo "Error: " . $e->getMessage(); exit; } ?>