44 lines
1.6 KiB
PHP
44 lines
1.6 KiB
PHP
<?php
|
|
require_once __DIR__ . '/db/config.php';
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
$name = trim($_POST['name'] ?? '');
|
|
$email = trim($_POST['email'] ?? '');
|
|
$company = trim($_POST['company'] ?? '');
|
|
$occupation = trim($_POST['occupation'] ?? '');
|
|
$relation = trim($_POST['relation'] ?? '');
|
|
$company_type = trim($_POST['company_type'] ?? '');
|
|
$linkedin_url = trim($_POST['linkedin_url'] ?? '');
|
|
|
|
if (empty($name) || empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
|
header('Location: index.php?status=error');
|
|
exit;
|
|
}
|
|
|
|
try {
|
|
$pdo = db();
|
|
$stmt = $pdo->prepare(
|
|
"INSERT INTO attendees (name, email, company, occupation, relation, company_type, linkedin_url) VALUES (:name, :email, :company, :occupation, :relation, :company_type, :linkedin_url)"
|
|
);
|
|
$stmt->bindParam(':name', $name, PDO::PARAM_STR);
|
|
$stmt->bindParam(':email', $email, PDO::PARAM_STR);
|
|
$stmt->bindParam(':company', $company, PDO::PARAM_STR);
|
|
$stmt->bindParam(':occupation', $occupation, PDO::PARAM_STR);
|
|
$stmt->bindParam(':relation', $relation, PDO::PARAM_STR);
|
|
$stmt->bindParam(':company_type', $company_type, PDO::PARAM_STR);
|
|
$stmt->bindParam(':linkedin_url', $linkedin_url, PDO::PARAM_STR);
|
|
|
|
$stmt->execute();
|
|
|
|
header('Location: index.php?status=success');
|
|
exit;
|
|
} catch (PDOException $e) {
|
|
// In a real app, log this error.
|
|
header('Location: index.php?status=error');
|
|
exit;
|
|
}
|
|
} else {
|
|
header('Location: index.php');
|
|
exit;
|
|
}
|