<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>User Form</title>
</head>
<body>
<h2>User Registration Form</h2>
<form action="process_form.php" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required><br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br><br>
<label for="age">Age:</label>
<input type="number" id="age" name="age" required><br><br>
<label for="gender">Gender:</label>
<select id="gender" name="gender" required>
<option value="male">Male</option>
<option value="female">Female</option>
<option value="other">Other</option>
</select><br><br>
<label for="dob">Date of Birth:</label>
<input type="date" id="dob" name="dob" required><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
.........................................................
<?php
if ($_SERVER["REQUEST_METHOD"] === "POST") {
// Store form data in variables
$username = $_POST['username'];
$password = $_POST['password'];
$age = $_POST['age'];
$gender = $_POST['gender'];
$dob = $_POST['dob'];
// Display the data
echo "Username: $username<br>";
echo "Password: $password<br>";
echo "Age: $age<br>";
echo "Gender: $gender<br>";
echo "Date of Birth: $dob<br>";
} else {
echo "Invalid request.";
}
?>
0 Comments
I really appreciate for your words. Thank you very much for your comment.