generated from Templates_CodeFirst/templateHtmlCss
ajout process.php
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
f057828259
commit
b1fd6ad33a
@ -0,0 +1,26 @@
|
|||||||
|
<?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>";
|
||||||
|
}
|
||||||
|
?>
|
Loading…
Reference in new issue