Creating a web form to capture identifying information, contact information, and family heritage requires a combination of HTML for the structure, CSS for styling, and JavaScript to manage form submission. However, note that sending an email directly from HTML/JavaScript is not feasible by itself due to security and functionality limitations in web browsers. Instead, you'd typically use a server-side language (like PHP, Node.js, etc.) to handle email sending.
For demonstration purposes, I will provide you with a simple HTML form, and I'll explain how you could integrate it with a server-side solution naively. You would need to handle email sending on the server after the form is submitted.
Example HTML Web Form
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Family Heritage Information Form</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
padding: 20px;
border: 1px solid #ccc;
border-radius: 10px;
max-width: 600px;
}
input, textarea {
width: 100%;
padding: 10px;
margin: 10px 0;
border-radius: 5px;
border: 1px solid #ccc;
}
button {
padding: 10px 15px;
font-size: 16px;
cursor: pointer;
background-color: #28a745;
color: white;
border: none;
border-radius: 5px;
}
</style>
</head>
<body>
<h1>Family Heritage Information Form</h1>
<form id="heritageForm" action="your-server-side-script.php" method="POST">
<h2>Identifying Information</h2>
<input type="text" name="fullName" placeholder="Full Name" required>
<input type="date" name="dateOfBirth" placeholder="Date of Birth" required>
<h2>Contact Information</h2>
<input type="email" name="email" placeholder="Email Address" required>
<input type="tel" name="phone" placeholder="Phone Number">
<h2>Family Heritage</h2>
<textarea name="heritage" placeholder="Describe your family heritage..." rows="5" required></textarea>
<button type="submit">Submit</button>
</form>
</body>
</html>
Explanation
-
HTML Structure:
- The form captures identifying information (full name, date of birth), contact information (email, phone number), and family heritage using a textarea.
- Each input field is required for submission.
-
CSS Styles:
- Basic styles for the form, inputs, and the submit button for a more user-friendly appearance.
-
Form Submission:
- The form uses the
POST method to send data to your-server-side-script.php. You would replace this with your actual server-side script.
Server-Side Handling (PHP Example)
Here is an example of what the PHP script (your-server-side-script.php) could look like to handle the form submission and send the email:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$fullName = $_POST['fullName'];
$dateOfBirth = $_POST['dateOfBirth'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$heritage = $_POST['heritage'];
$to = 'recipient@example.com'; // Replace with your recipient email
$bcc = 'bccperson@example.com'; // Replace with your BCC email
$subject = 'Family Heritage Information Submission';
$message = "Name: $fullName\n";
$message .= "Date of Birth: $dateOfBirth\n";
$message .= "Email: $email\n";
$message .= "Phone: $phone\n";
$message .= "Heritage: $heritage\n";
$headers = "From: $email\r\n";
$headers .= "Bcc: $bcc\r\n";
if (mail($to, $subject, $message, $headers)) {
echo "Email sent successfully!";
} else {
echo "Email sending failed.";
}
}
?>
Important Notes
-
Email Security: The mail function in PHP might require proper server configuration and validation (e.g., through SMTP). Always validate and sanitize user input to avoid security vulnerabilities.
-
Deployment: You need a server with PHP enabled to use the PHP script. You cannot run PHP code locally unless you set up a server environment like XAMPP, MAMP, or a web hosting service.
-
Testing: To test this system, you will need proper email configuration and permissions to send emails, which will vary based on the server environment and settings.
With this structure, users can fill out the form, and when submitted, the information will be sent via email as specified.