generated from Templates_CodeFirst/templateHtmlCss
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
1.0 KiB
26 lines
1.0 KiB
<?php
|
|
// Check if the form was submitted
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
|
|
// Sanitize and retrieve form inputs
|
|
$last_name = htmlspecialchars(trim($_POST['last_name']));
|
|
$first_name = htmlspecialchars(trim($_POST['first_name']));
|
|
$age = isset($_POST['age']) ? (int)$_POST['age'] : null; // Optional, so we check if it's set
|
|
$gender = htmlspecialchars(trim($_POST['gender']));
|
|
|
|
// Check required fields
|
|
if (!empty($last_name) && !empty($first_name)) {
|
|
// Process form data (e.g., store in a database, display, etc.)
|
|
echo "<h1>Form Submitted Successfully!</h1>";
|
|
echo "<p>Last Name: " . $last_name . "</p>";
|
|
echo "<p>First Name: " . $first_name . "</p>";
|
|
echo "<p>Age: " . ($age !== null ? $age : 'Not provided') . "</p>";
|
|
echo "<p>Gender: " . $gender . "</p>";
|
|
} else {
|
|
// Handle missing required fields
|
|
echo "<p>Error: First name and last name are required.</p>";
|
|
}
|
|
} else {
|
|
echo "<p>No form was submitted.</p>";
|
|
}
|
|
?>
|