setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("INSERT INTO activities (name, surname, age) VALUES (:name, :surname, :age)");
$stmt->bindParam(':name', $_POST['fname']);
$stmt->bindParam(':surname', $_POST['lname']);
$stmt->bindParam(':age', $_POST['age']);
$stmt->execute();
echo "Data inserted.
";
} catch (PDOException $e) {
echo "Error!: " . $e->getMessage() . "
";
}
}
?>